Jump to content

Help With Coding


IncrediBody.com

Recommended Posts

I have been using a php form for some time now and all of a sudden it has stopped working.  We have not changed anything at all in the code and before it was working fine.  The company that hosts our website thinks it may have to do with it not being compatible with php5 (they recently changed over all their sites to that).  I was hoping someone could look this over and see what changes would be necessary:

 

<!doctype html public "-//w3c//dtd html 3.2//en">


<html>

<head>
<title>IncrediBody.com - Custom Price Quote</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<style type="text/css">
<!--
body,td,th {
color: #000000;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#0000FF" alink="#FF0000">


<table border="0" cellpadding="0" cellspacing="0" width="300">
    <tr>    
<td width=55> 
            
        </td>
        <td >
            <?

$form_block = "
<table border=\"0\" cellpadding=\"0\"  cellspacing=\"0\" id=text>
<FORM METHOD=\"post\" ACTION=\"$PHP_SELF\">
    <tr><td  height=\"20\" align=center id=clientstitle><strong>Want a Lower Price?</strong></td>    </tr>
    <tr><td  height=\"20\" align=center id=clientstitle><br><strong>We can save you money on most orders over $100.  Please fill in the form below to get a custom price quote.  Your phone number is not required, but gives us another contact method in addition to your e-mail address to reach you.  Please be as detailed as possible when listing the items that you want the price quote for in order to get the most accurate response.  Your city, state, and zip code are collected in order for us to calculate the cost to ship the item to you.</strong></td>    </tr>
</td>    
</tr>


    <tr>

<td height=20 >   </td></tr>
                        <tr><tr><td >
<P><strong>Your First Name:</strong><br>
<INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\" SIZE=30></p>

<P><strong>Your E-Mail Address:</strong><br>
<INPUT type=\"text\" NAME=\"sender_email\"  VALUE=\"$sender_email\" SIZE=30></p>


<P><strong>Your Phone Number (not required):</strong><br>
<INPUT type=\"text\" NAME=\"sender_phone\"  VALUE=\"$sender_phone\" SIZE=30></p>

<P><strong>City:</strong><br>
<INPUT type=\"text\" NAME=\"sender_city\"  VALUE=\"$sender_city\" SIZE=30></p>


<P><strong>State:</strong><br>
<INPUT type=\"text\" NAME=\"sender_state\"  VALUE=\"$sender_state\" SIZE=30></p>


<P><strong>Zip Code:</strong><br>
<INPUT type=\"text\" NAME=\"sender_zip\"  VALUE=\"$sender_zip\" SIZE=30></p>

<P><strong>Country:</strong><br>
<INPUT type=\"text\" NAME=\"sender_country\"  VALUE=\"$sender_country\" SIZE=30></p>

<P><strong>List the items (and quantity of that item you want) for a custom price quote:</strong><br>
<TEXTAREA NAME=\"message\" COLS=24 ROWS=6 WRAP=virtual>$message</TEXTAREA></p>

<INPUT type=\"hidden\" name=\"op\" value=\"ds\">

<P align=center><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit for Price Quote\" class=buttons></p>
<P align=center><INPUT TYPE=\"reset\" NAME=\"reset\" VALUE=\"Reset Form\" class=buttons></p>


</FORM>
</td></tr></table>


";

if ($op != "ds") {

    // This are the error messages on the required fields you can add or delete
    echo "$form_block";
    
} else if ($op == "ds") {

    
    if ($sender_email == "") {
        $email_err = "<font color=red size=3>ERROR: Please write your e-mail address below!</font><br>";
        $send = "no";
        } 

    
    if ($message == "") {
        $message_err = "<font color=red size=3>ERROR: Please write your message below!</font><br>";
        $send = "no";
    } 


function check_email($str)
{
//returns 1 if valid email, 0 if not
if(ereg("^.+@.+\\..+$", $str))
	return 1;
else
	return 0;
}


if(!check_email($sender_email)){
        $email_err = "<font color=red size=3>ERROR: Please write a correct e-mail address below!</font><br>";
        $send = "no";
        } 










    
    if ($send != "no") {
    
        // this is the info that comes on the email when it's ok to send!
        $msg = "IncrediBody.com - Custom Price Quote\n";
        $msg .= "Sender's Name:    $sender_name\n";
        $msg .= "Sender's E-Mail:  $sender_email\n";
$msg .= "Sender's Phone:  $sender_phone\n";
          $msg .= "City:  $sender_city\n";
$msg .= "State:  $sender_state\n";
$msg .= "Zip Code:  $sender_zip\n";
$msg .= "Country:  $sender_country\n";
        $msg .= "Message:          $message\n\n";    
  $fortwo = "esa";
  $forthree = "le@muscle";
  $forfour = "withoutsupplements.c";
  $forfive = "om";
        $to = "whol" . $fortwo . $forthree . $forfour . $forfive;
        $subject = "IncrediBody.com - Custom Price Quote";
        $mailheaders = "From: Information\n \n";
        $mailheaders .= "Reply-To: $sender_email\n\n";

        mail($to, $subject, $msg, $mailheaders);
        echo " <center>Thank you for submitting a custom price quote.  We will review it and then get back to you with your custom price.</center>


<h1><center><b><u>IMPORTANT NOTE</u></b></center></h1>


If <font color=ff0000>$sender_email</font> is NOT your email address, then please submit this form again or else we can't respond to your price quote.  MAKE SURE THAT <font color=ff0000>$sender_email</font> IS THE CORRECT EMAIL ADDRESS, OTHERWISE WE WILL HAVE NO WAY OF REPLYING TO YOUR PRICE QUOTE!  If you do not receive a response from us, there may be a problem with your email address, and you must submit the custom price quote again using a different email account (visit www.hotmail.com to set up a free email address).  If <font color=ff0000>$sender_email</font> is a valid, properly functioning email address, then you will be receiving a reply from us very soon!  
";
    } else if ($send == "no") {
    
        echo "$name_err";
        echo "$email_err";
          echo "$company_err";
        echo "$message_err";
        echo "$form_block";  
            
    } 
    
}

?>
<p> </p>
</body>

</html>

Link to comment
Share on other sites

Your host is right, your script reply's on old outdated coding techniques as it requires register_globals to be enabled. register_globals is now disabled by default and is soon to be removed completely as of PHP6.

 

You should use superglobal variables instead

 

A basic run down of the variables,

$_GET - receive variables from the url, example variable $_GET['foo'], example url yousite.com?foo=bar

$_POST - used to access POST data once a form has been submitted, example $_POST['your_field_name']

$_COOKIE - receive a cookie values, eg $_COKIE['cookie_name']

$_SESSION - all session data is set within this variable, $_SESSION['var_name']

$_SERVER - receive a server declared variable, eg $_SERVER['PHP_SELF']

Link to comment
Share on other sites

Your host is right, your script reply's on old outdated coding techniques as it requires register_globals to be enabled. register_globals is now disabled by default and is soon to be removed completely as of PHP6.

 

You should use superglobal variables instead

 

A basic run down of the variables,

$_GET - receive variables from the url, example variable $_GET['foo'], example url yousite.com?foo=bar

$_POST - used to access POST data once a form has been submitted, example $_POST['your_field_name']

$_COOKIE - receive a cookie values, eg $_COKIE['cookie_name']

$_SESSION - all session data is set within this variable, $_SESSION['var_name']

$_SERVER - receive a server declared variable, eg $_SERVER['PHP_SELF']

 

Thanks for this.  I still don't quite understand what needs to be changed.  Would it be possible to give a few examples based on the code I posted?

Link to comment
Share on other sites

Try changing your form input tags to something like this:

 

<?php
echo "<input name=\"sender_name\" type=\"text\" id=\"sender_name\">";
?>

 

And put this on the next page between your php tags to pass the variable to that page:

 

<?php
$sender_name=$_POST['sender_name'];
?>

 

If you do this you can use the variable $sender_name on page 2.

Hope this helped out.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.