Reputation: 9
My PHP will not work. I'm trying to use $_POST
to collect information from the form and nothing is coming up.
Here is the HTML code:
<form action="test2.php" method="post">
First Name:<br />
<input type="text" name="firstname" /><br />
Last Name:<br />
<input type="text" name="lastname" /><br /><br /><br />
Address:<br />
<input type="text" name="address" /><br />
City:<br />
<input type="text" name="City" /><br />
Province:<br />
<input type="text" name="province" /><br /><br /><br />
Phone:<br />
<input type="text" name="phone" /><br />
Email<br />
<input type="text" name="email" /><br /><br /><br />
Select Desired Apartment: <br />
<input type="checkbox" name="type" value="onebed" />One Bedroom<br />
<input type="checkbox" name="type" value="twobed" />Two Bedroom<br />
<input type="checkbox" name="type" value="threebed" />Three Bedroom<br /><br /><br />
Rental Type:<br />
<input type="radio" name="renttype" value="weekly" />Weekly<br />
<input type="radio" name="renttype" value="monthly" />Monthly<br /><br /><br />
Start Date:<br /><input type="date" name="startingdate" /><br /><br /><br />
<input type="submit" value="Submit" />
</form>
Here is test2.php
<!DOCTYPE HTML>
<html>
<body>
Registration_Number: <br />
Name: <?php echo $_POST['firstname']; ?> <br />
Address: <?php echo $_POST['address']; ?> <br />
Email: <?php echo $_POST['email']; ?> <br />
Appartment_Type: <br />
Rental_Type: <br />
Starting_Date: <?php echo $_POST['startingdate']; ?> <br />
</body>
</html>
Thanks for the help!
Upvotes: 0
Views: 84
Reputation: 10120
try adding value
attributes to all your input tags. Sometimes browsers will not send these fields. You would see a blank page if you do not have PHP configured to display errors.
<form action="test2.php" method="post">
First Name:<br />
<input type="text" name="firstname" value="" /><br />
Last Name:<br />
<input type="text" name="lastname" value="" /><br /><br /><br />
Address:<br />
<input type="text" name="address" value="" /><br />
City:<br />
<input type="text" name="City" value="" /><br />
Province:<br />
<input type="text" name="province" value="" /><br /><br /><br />
Phone:<br />
<input type="text" name="phone" value="" /><br />
Email<br />
<input type="text" name="email" value="" /><br /><br /><br />
Select Desired Apartment: <br />
<input type="checkbox" name="type" value="onebed" />One Bedroom<br />
<input type="checkbox" name="type" value="twobed" />Two Bedroom<br />
<input type="checkbox" name="type" value="threebed" />Three Bedroom<br /><br /><br />
Rental Type:<br />
<input type="radio" name="renttype" value="weekly" />Weekly<br />
<input type="radio" name="renttype" value="monthly" />Monthly<br /><br /><br />
Start Date:<br /><input type="date" name="startingdate" value="" /><br /><br /><br />
<input type="submit" value="Submit" />
</form>
Upvotes: 0
Reputation: 18923
First assure php is working properly
create a test php file with this
<?php
echo "it's working";
and navigate to it using the browser
it should show the message it's working
Second step is assuring everything is working with your form.
change your test2.php to this:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
var_dump($_POST);
you should see the values of the form posted
Upvotes: 1