Jump to content

[SOLVED] PHP 4.4.7 - _POST vars not showing up in generated email


dj_meatwad

Recommended Posts

Hello - first off, please forgive me if this has already been answered.  I was unable to find a solution by searching, but it's possible I didn't search on the correct terms.  In any case, here's the issue:

 

My hosting provider, Lunarpages, recently upgraded PHP from 4.4.4 to 4.4.7.  I had a couple of HTML forms that were sending data to a PHP script, which used data from said HTML form to generate, and send, an email.  After the upgrade to 4.4.7, however, the _POST variables in the PHP are not showing up in the generated email.  I'll paste the code in here now; perhaps there's something I've done incorrectly:

 

PHP code:

 

<?php

if ($_POST['user'] != "" && $_POST['requested'] ) {
$subject="Request!";
$ip=$_SERVER["REMOTE_ADDR"];
$host = $ip;
$mon=date(m);
$day=date(j);
$year=date(y);
$hour=date(g);
$min=date(i);
$sec=date(s);
$hour=$hour-2;
if($hour<=0) { $hour+=12; }
$ts = "$hour:$min:$sec on $mon/$day/$year";

$nsuser = stripslashes($user);

$body="

Your Name = $nsuser

Song Requested = $requested

Dedication = $dedication

Host: $host
Time: $ts";

$email = "From: Form <$to>";
mail($to, $subject, $body, $email);
header("Location: xxx.php");

}
?>

 

... and the HTML form that calls it:

 

<form method="post" action="req_form.php">
Your Name (required):<br>
<input type="text" name="user" style="border: 1px solid #cccccc; background-color: #ffffff;" size="26" value=""><br>
Song Requested (required, artist & song title please!):<br>
<input type="text" name="requested" style="border: 1px solid #cccccc; background-color: #ffffff;" size="26" value=""><br>
Dedication? (may be read on air):<br>
<input type="text" name="dedication" style="border: 1px solid #cccccc; background-color: #ffffff;" size="26" value=""><br>
<input type="submit" value="send" style="border: 1px solid #cccccc; background-color: #ffffff;">
</form>

 

With this, the email is generated and sent, with entirely blank fields, regardless of what the user enters into the form.

 

Again, this worked just fine with PHP 4.4.4.  Any help/advice/assistance anyone can provide here would be most appreciated.  If more information is required, please let me know.

 

Thanks in advance!

You register_globals setting was probably changed meaning your going to have to start defining your variables from forms actually using $_POST.

 

So you would change lines like this

$nsuser = stripslashes($user);

 

To

$nsuser = stripslashes($_POST['user']);

 

 

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.