My website has a feature when a user can submit a link to the website. This link is submitted using a form that submits to a php page using the GET method. My issue is that when the user clicks "Submit" on the form the URL changes and the user is taken to a black white page. Is there a method of submitting data without the redirecting to a new page?
the submit form:
<form action="submitvid.php" method="get">
<font size="+1">Submit A Video: </font>
<input type="text" name="submittedurl" />
<input type="submit" />
the php page:
$videourl=$_GET["submittedurl"];
From your code, i feel that you are redirecting the user to submitvid.php which might be different from where the above form exists.
If not, then you have a header() thing in your PHP code that redirects to a blank page
Considering your form page is PHP: On same page leave action empty action=""
server will assume submission on same page and you can put a check at top:
if(isset($_GET["submittedurl"])) {
//save url here
}
Considering your form page is Simple HTML: In submitvid.php after saving url you can redirect back user to old page. header("Location: index.html")
Either do the process in the same page (ex: index.php
), so you'll put this a the begining of the file:
// index.php file
if ( isset($_GET["submittedurl"]) ){
$videourl=$_GET["submittedurl"];
// do everything you want to the url
}
or redirect from the submitvid.php
page after the work is done using header()
//submitvid.php file
$videourl=$_GET["submittedurl"];
// what you want to do with $videourl
header('location: index.php');
or use AJAX
you can submit it to the same page that you are , or you can use AJAX. or you can submit it to a new page, and you redirect it again using :
<?php header("location: example.php"); ?>