Jump to content

[SOLVED] PHP/HTML Form


goosefrikin

Recommended Posts

Hi, just started playing around with php yesterday and i've unfortunately hit a dead end

 

Here is a php and HTML code that I retrieved from an online tutorial:

<html>
<title>Processing Forms</title>
<body>
<form method="POST" action="process.php">
Name: <input type="text" name="name">
<p>
Sex: <input type="radio" name="sex" value="M"> Male
<input type="radio" name="sex" value="F"> Female
<p>
Annual Income:
<select name="income">
<option value="$25,000">Under $25,000
<option value="$25,000 to $50,000">$25,000 to $50,000
<option value="$50,000 and higher">$50,000 and higher
</select>
<p>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

 

and here's the php code

<html>
<head>
<title>process.php</title>
</head>
<body>
<?php
print "Name: <b>$_POST['name']</b><br />";
print "Sex: <b>$_POST['sex']</b><br />";
print "Annual income: <b>$_POST['income']</b><br />";
?>
</body>
</html>

 

i am able to go through the html and click submit but the php code doesn't do anything...like the resulting website just gives me this:

$_POST['sex']

"; print "Annual income: $_POST['income']

"; ?>

 

I have no idea whats wrong..ive tried many different tutorials with HTML forms and PHP and i get the same result. Please help!!!

Link to comment
https://forums.phpfreaks.com/topic/150982-solved-phphtml-form/
Share on other sites

ok here's what i did

 

i saved the html as tut10.html and saved the php as process.php

 

then i open tut10.html and it takes me to a webpage on firefox in which the html form appears...i then enter data into it and i click submit and that subsequently sends me to process.php and that is where the problem lies as this

$_POST['sex']

"; print "Annual income: $_POST['income']

"; ?>

appears on that page

 

wolf i did try phpinfo when i first started using php and it did work and i have done a couple of other tutorials today and theyve all worked

Link to comment
https://forums.phpfreaks.com/topic/150982-solved-phphtml-form/#findComment-793238
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.