Forum Moderators: coopster

Message Too Old, No Replies

new wrinkle old form

         

Gilead

7:48 pm on Nov 19, 2011 (gmt 0)

10+ Year Member



I am currently converting my project to use $_SESSION variables.

Since the conversion, the email form no longer works.
change.php
<?php
//prevents caching
header("Expires: Fri, 01 Jan 1988 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="created" content="Tue, 15 Nov 2011 16:44:09 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<!-- <meta http-equiv="refresh" content="5; url=index.php"> -->
<title>Change User Information</title>

<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<?php
$to='testing@mydomain.com';
$changeitem=$_POST['changeitem'];
$whychange=$_POST['whychange'];
$email=$_POST['email'];
$contactid=$_SESSION['id'];
$accountnumber=$_POST['account_number'];
$organization=$_POST['organization_title'];
$accountname=$_POST['account_name'];
$dba=$_POST['organizationDBA'];
$networkrep=$_POST['network_representative'];
$network=$_POST['network'];
$fname=$_POST['firstname'];
$lname=$_POST['lastname'];


$subject = "Member Change Form";
$headers = "From: $email \r\n";
$body = "This member needs to change:\n";
$body .= implode(', ',$changeitem)."\n";
$body .= "Purpose for Change: '$whychange' \n";
$body .= "Contact Id: '$contactid' \n";
$body .= "Account Number: '$accountnumber' \n";
$body .= "Org Title: '$organization' \n";
$body .= "Account Name; '$accountname' \n";
$body .= "DBA: '$dba' \n";
$body .= "Rep: '$networkrep' \n";
$body .= "Network: '$network' \n";
$body .= "First Name: '$fname' \n";
$body .= "Last Name: '$lname' \n";
$body .= "Email: '$email' \n";

if(mail($to,$subject,$body,$headers))
{
echo "Request made. We will contact you within 24 business hours.";
echo "You'll be tranferred to your page within 5 seconds.";
echo $to;
echo '<br />';
echo $subject;
echo '<br />';
echo $body;
echo '<br />';
echo $headers;
echo '<br />';
//Everything prints out just fine, it just will not send for some reason. Any thoughts?
}
else
{
echo "Message Not Sent";
}
?>
</body>
</html>
change.php
Just in case, here is the source form:
<form method="POST" name="changebig" action="change.php">
<h3>What do you need to change?</h3>
<input type="checkbox" name="changeitem[]" value="accountnumber"><b>account number</b><br />
<input type="checkbox" name="changeitem[]" value="contactid"><b>contact id</b><br />
<input type="checkbox" name="changeitem[]" value="orgname"><b>organization name</b><br />
<input type="checkbox" name="changeitem[]" value="accountname"><b>account name</b><br />
<input type="checkbox" name="changeitem[]" value="networkrep"><b>network representative</b><br />
<input type="checkbox" name="changeitem[]" value="network"><b>network</b><br />
<input type="hidden" name="login" value="<?php echo $member_login; ?>">
<input type="hidden" name="password" value="<?php echo $member_password; ?>">
<input type="hidden" name="title" value="<?php echo $title; ?>">
<input type="hidden" name="salutation" value="<?php echo $salutation; ?>">
<input type="hidden" name="firstname" value="<?php echo $firstname; ?>">
<input type="hidden" name="lastname" value="<?php echo $lastname; ?>">
<input type="hidden" name="commethod" value="<?php echo $communication_method; ?>">
<input type="hidden" name="phone" value="<?php echo $phone; ?>">
<input type="hidden" name="mobile" value="<?php echo $mobile; ?>">
<input type="hidden" name="other" value="<?php echo $otherphone; ?>">
<input type="hidden" name="fax" value="<?php echo $fax; ?>">
<input type="hidden" name="emailopt" value="<?php echo $email_opt_out; ?>">
<input type="hidden" name="email" value="<?php echo $email; ?>">
<textarea name="whychange" rows="5" cols="25">Please explain what has occurred that necessitates these changes.</textarea><br />
<input type="submit" name="submit" value="Change"><input type="reset">
</form>

Is is a positional kind of thing?
Thanks!

Habtom

8:20 pm on Nov 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two questions:

  • Are SESSIONs really important for your contact form?[/li]
  • What sort of error are you getting?[/li]

    Most likely solution:
    Drag up session_start(); to the very top like this
    <?php
    session_start();
    ... the rest of the code


    You need a better security for your contact form, the way it is you are open for easy attacks.
  • Gilead

    10:39 pm on Nov 20, 2011 (gmt 0)

    10+ Year Member



    I was using the session variable for the contactid, only the form seems to work, but no email is received. It worked previously when I wasn't using the session variable. I'll look at security more after it is working. The session start is at the very top, even prior to the HTML.

    When is it best to use session variables? I was trying to be consistent, by having them on every page.