Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
am trying to make a signup form but the problem is
that when i hit button it will take to my
signup source and the following in my browser
first=francis&last=chijioke&uid=alert&pwd=1234

What I have tried:

index.php


<!DOCTYPE html>


<meta charset = "UTF-8">
<title>my_school



<br>
<br>
<br>
<br>
SIGN UP




signup.php


<?php

include 'dbh.php';

$first = $_POST['first'];
$last = $_POST['last'];
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];

echo $first."<br>";
echo $last."<br>";
echo $uid."<br>";
echo $pwd."<br>";

?>

dbh.php

<?php

$conn = mysqli_connect("localhost", "root", "", "logintest");

if(!$conn){
   die("Connection failed".mysqli_connect_error());
}

?>
Posted
Updated 9-May-17 1:22am

1 solution

Your index page does not show anything; the HTML form is not here, perhaps somewhere else. However, the problem you are facing is, because you are using HTTP GET communication verb. You need to use POST verb, to hide all of that information from URL and add in the headers or body of the request.

Fix is as simple as,
HTML
<form method="post">
   <!-- Your HTML content here, add enctype, action etc. -->
</form>

Once this form gets published, it will submit the form data, by adding the form information in the body of the request and not in the URL.

For more on this please read,
HTTP request methods - HTTP | MDN[^]
<form> - HTML | MDN[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900