Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

when I submit my form values not passed

Status
Not open for further replies.

tom11011

MIS
Oct 12, 2001
537
US
Hello all, this is killing me. This little web program has worked on another linux server with apache and php but I can't figure out why my web form will not pass it's values.

Basically, the user goes to index.html and fills out a form. Then, when they click submit, it is posted to a php file that sends an email. The email sends ok, just doesn't have anything in the values, they are blank.

here is the 2 short pages:

index.html
----------
<HTML>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY>
<FORM METHOD="POST" action="form_mail.php">
<table>

<tr>
<td>Status:</td><td><font size=-6 face=verdana><input type="radio" name="status" value="New Hire">New Hire <input type="radio" name="status" value="Separation">Separation <input type="radio" name="status" value="ReHire">Rehire <input type="radio" name="status" value="Transfer">Transfer</td>
</tr>
</table>


<input type=submit value="Submit">

</form>
</BODY>
</HTML>


form_mail.php
-------------
<HTML>
<TITLE>
test
</TITLE>
<body>

<?php

$email_to = "user@test.com";

$subject = "* test subject *";

$message = "* test message *\n\n
Status: ". $status ."\n\n
Employee: ". $name ."\n\n
Title: ". $title ."\n\n
Manager: ".$manager ."\n\n
Date: ". $date ."\n\n
Location: ".$location ."\n\n
Comments: ". $comments ."\n";

$email_from = "From:test@test.com";

mail($email_to,$subject,$message,$email_from);


?>
</body>
</HTML>
 
your problem is the security added to php. Replace the name of the variable with $_POST["variable"]

eg:

Code:
Status: ". [red]$_POST["$status"][/red] ."\n\n

Cheers.

Chacal, Inc.
 
Hi,
You're accessing the variables wrong:

Try this:
(assuming all variables referenced are coming from form on previous page)
form_mail.php:
Code:
<HTML>
<TITLE>
test
</TITLE>
<body>

<?php

$email_to = "user@test.com";

$subject = "* test subject *";

$message = "* test message *\n\n
Status: ". $_POST['status'] ."\n\n
Employee: ". $_POST['name'] ."\n\n
Title: ". $_POST['title'] ."\n\n
Manager: ".$_POST['manager'] ."\n\n
Date: ". $_POST['date'] ."\n\n
Location: ".$_POST['location'] ."\n\n
Comments: ". $_POST['comments'] ."\n";

$email_from = "From:test@test.com";

mail($email_to,$subject,$message,$email_from);


?>
</body>
</HTML>

[cheers]
Cheers!
Laura
 
the parameter in php.ini is "register_globals" that you should have it in "off".

So, if your form has a methos "GET" you should get the values as $_GET["var"] and for "POST" with $_POST["var"].

Cheers.

Chacal, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top