Jump to content

PHP form no longer working


ahollenb

Recommended Posts

Hi, thanks in advance for any help here.  I have a PHP 'contact us' form on my website that recently stopped returning the information that gets entered into the form.  I don't know why it's no longer working and was hoping someone here could help.  It's worked for the last 4 years and only stopped working within the last week.  I still get the email, but none of the information is returned, only blanks.  Any ideas?

 

Here's the script I'm using:

<?php

      /*----------------------*/ 
      /*   URL of the site.   */
      /*----------------------*/
      $site_URL    =    "http://www.Website.com/";       
      
      /*----------------------*/ 
      /*   Name of the site.   */
      /*----------------------*/
      $site_Name    =    "Website.com";                   
      
      /*----------------------*/ 
      /*   ADMIN email id.   */
      /*----------------------*/
      $admin_from =    "webmaster@Website.com";
      
      /*----------------------*/ 
      /*   ADMIN email id to which comments are sent.   */
      /*----------------------*/
      $admin_email =    "info@Website.com";
      

   
   $name =     $_REQUEST["firstname"];
   $lastname = $_REQUEST["lastname"];
   $email =    $_REQUEST["email"];
   $zipcode =  $_REQUEST["zipcode"];
   $phone =    $_REQUEST["phone"];
   $message =  $_REQUEST["message"];

   $subject = "$site_Name has Received your Message";
        
   $sendmessage = "<font face='tahoma, verdana, arial, helvetica' size=2>New Comments Received...<br><br>";
   $sendmessage .= "<strong>Name:</strong> $name $lastname<br>";
   $sendmessage .= "<strong>Zipcode:</strong> $zipcode<br>";
   $sendmessage .= "<strong>Phone:</strong> $phone<br>";
   $sendmessage .= "<strong>Email:</strong> <a href='mailto:$email' style='color:#6095cc; text-decoration: none;'>$email</a><br>";
   $sendmessage .= "<strong>Message:</strong> $message<br>";
   
   $sendmessage .= "<br><a href='$site_URL' target=_blank>$site_Name</a></font>";
       
   $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
   $headers .="From: $site_Name Registration <$admin_from>\n";
   
   
   mail($admin_email, $subject, $sendmessage, $headers);
   
      
   $reply_msg = "<font face='tahoma, verdana, arial, helvetica' size=2>Thank you for your comments at $site_Name.  We will reply soon!<br>";
   $reply_msg .= "<br>- <a href='$site_URL' target=_blank>$site_Name</a></font>";
   
   $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
   $headers .="From: $site_Name<$admin_from>\n";
   
   // send an email to confirm the referer.
   mail($email, "$site_Name - Your comments have been received!", $reply_msg, $headers);
   
?>


<center>
  <font face='tahoma, verdana, arial, helvetica' color='#333333'>
  <h2>
    <?=$site_Name?>
  </h2>
  <p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Please wait while your comments are being sent.</strong>.<br />
    If your page does not refresh automatically, <a href="<?=$site_URL?>">Click Here</a>.</font></p>
</center>
<script language="javascript">   
   window.location.href = "<?=$site_URL?>";
</script>

 

MOD EDIT:

 . . . 

BBCode tags added.

Link to comment
Share on other sites

Thanks for your quick reply!  I suspected that too, so I called Yahoo Stores (where my store is hosted) and they said it must be the PHP script.  So, now I'm really not sure where the problem lies.

 

This is the form script that calls the contact.php script:

<script language="javascript" type="text/javascript">

function validate(frm)
{
firstname = frm.firstname;
lastname = frm.lastname;
zipcode = frm.zipcode;
phone = frm.phone;
email = frm.email;
message = frm.message;
err_flag = 0;
if (firstname.value == "" || !removeSpaces(firstname.value))
  {
   alert ("Please enter First Name!");
   firstname.focus();
   firstname.value="";
   return false; 
  }
   else if (lastname.value == "" || !removeSpaces(lastname.value))
   {
    alert ("Please enter Last Name!");
    lastname.focus();
    lastname.value="";
    return false; 
   }
  else if (email.value == "" || !validate_email(email.value))
   {
   alert ("Please enter valid Email!");
   email.focus();
   return false; 
  }
    else if (message.value == "" || !removeSpaces(message.value))
    {
     alert ("Please enter Message!");
     message.focus();
     message.value="";
     return false; 
    }
    }
    
    function validate_email(e)
{
var str=e;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(str))
  return false;
else
  return true;
}function removeSpaces(string) {
var tstring = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
tstring += splitstring;
return tstring;
}
</script></p>
<table id="table1">
   <tr>
      </td>
   </tr>
</table>
<div align="left">
   <table id="table2">
      <tr>
         <td class="td-caption" width="40%" align="right">
         <p><font color="#FF0000"><i>*Required </i></font></p>
         </td>
         </div>
      </tr>
   </table>
   <table align="center" border="0" cellpadding="2" cellspacing="2" width="100%">
      <tr>
         <td align="left">
         <form id="form1" name="form1" method="post" action="http://p11.hostingprod.com/@Website.com/php/contact.php" onsubmit="return validate(this);">
            <table border="0" bordercolor="#ffccff" cellpadding="2" cellspacing="4" width="90%">
               <tr>
                  <td class="td-caption" align="right" width="148">
                  <font color="#FF0000">*</font>First Name:</td>
                  <td>
                  <input name="firstname" id="firstname" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right">
                  <font color="#FF0000">*</font>Last Name:</td>
                  <td>
                  <input name="lastname" id="lastname" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right">
                  <font color="#FF0000">*</font>Email Address:</td>
                  <td>
                  <input name="email" id="email" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right">Zip Code:</td>
                  <td>
                  <input name="zipcode" id="zipcode" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right">Phone No:</td>
                  <td>
                  <input name="phone" id="phone" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right" valign="top">
                  <font color="#FF0000">*</font>Message:</td>
                  <td>
                  <textarea name="message" id="message" wrap="VIRTUAL" rows="4" cols="40"></textarea></td>
               </tr>
               <tr align="center">
                  <td colspan="2" id="Q" valign="top"></td>
               </tr>
               <tr>
                  <td align="right" valign="top"> </td>
                  <td>
                  <input name="Submit" value="Submit" class="button" type="submit"> 
                  <input name="Submit2" value="Reset" class="button" type="reset"></td>
               </tr>
            </table>
         </form>
         </td>
      </tr>
   </table>

 

MOD EDIT:

 . . . 

BBCode tags added.

Link to comment
Share on other sites

make sure the form action

action="http://p11.hostingprod.com/@Website.com/php/contact.php" 

is correct, since you are getting blank values where the variable values should be, I suspect that the form is failing to send the data to the correct file.

Link to comment
Share on other sites

Sorry I'm not understanding.  I added the code to the PHP script and then entered test info into the form & submitted.  I'm not sure how the values you're referring to get displayed or where they get displayed?  Could you clarify?  Thanks so much for your help!

Link to comment
Share on other sites

I did enter the code provided by PFM into the contact.php code.  Then, I filled in and submitted the form.  Then, I checked my email and received the following:

 

New Comments Received...

 

Name:

Zipcode:

Phone:

Email:

Message:

 

website.com

Link to comment
Share on other sites

I did enter the code provided by PFM into the contact.php code.  Then, I filled in and submitted the form.  Then, I checked my email and received the following:

 

New Comments Received...

 

Name:

Zipcode:

Phone:

Email:

Message:

 

website.com

 

PFM's code has nothing to do with the email.

It will output data on contact.php when the form is submitted.

What does contact.php look like in your browser when you submit the form.

Link to comment
Share on other sites

OK, I think I understand now.  The problem was that when I tried to view the PHP code, it would automatically send me to the  home page of my website.  I removed the code at the end that does that and then reviewed the PHP with PFM's code.  This is what I see:

 

POST:Array
(
)

Link to comment
Share on other sites

Something I found while searching around on google this morning was this PHP 5 ChangeLog on the PHP website - http://www.php.net/ChangeLog-5.php.

 

It's interesting that a number of changes, including removing 'legacy features', happened on Mar 1 2012, about the same timeframe that my form stopped working.

 

Is there anything in the Change Log that could account for my form breaking all of sudden after 4 years of working?

 

Thanks again for your help!  It really is appreciated.

 

Link to comment
Share on other sites

what's the chances of seing the actual form?

Sorry not sure what you mean.  I sent along the entire html code for the form in an earlier reply.  If you put this in a html editor, you'll see the form.  Here it is again:

 

<script language="javascript" type="text/javascript">

function validate(frm)
{
firstname = frm.firstname;
lastname = frm.lastname;
zipcode = frm.zipcode;
phone = frm.phone;
email = frm.email;
message = frm.message;
err_flag = 0;
if (firstname.value == "" || !removeSpaces(firstname.value))
  {
   alert ("Please enter First Name!");
   firstname.focus();
   firstname.value="";
   return false; 
  }
   else if (lastname.value == "" || !removeSpaces(lastname.value))
   {
    alert ("Please enter Last Name!");
    lastname.focus();
    lastname.value="";
    return false; 
   }
  else if (email.value == "" || !validate_email(email.value))
   {
   alert ("Please enter valid Email!");
   email.focus();
   return false; 
  }
    else if (message.value == "" || !removeSpaces(message.value))
    {
     alert ("Please enter Message!");
     message.focus();
     message.value="";
     return false; 
    }
    }
    
    function validate_email(e)
{
var str=e;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(str))
  return false;
else
  return true;
}function removeSpaces(string) {
var tstring = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
tstring += splitstring;
return tstring;
}
</script></p>
<table id="table1">
   <tr>
      </td>
   </tr>
</table>
<div align="left">
   <table id="table2">
      <tr>
         <td class="td-caption" width="40%" align="right">
         <p><font color="#FF0000"><i>*Required </i></font></p>
         </td>
         </div>
      </tr>
   </table>
   <table align="center" border="0" cellpadding="2" cellspacing="2" width="100%">
      <tr>
         <td align="left">
         <form id="form1" name="form1" method="post" action="http://p11.hostingprod.com/@Website.com/php/contact.php" onsubmit="return validate(this);">
            <table border="0" bordercolor="#ffccff" cellpadding="2" cellspacing="4" width="90%">
               <tr>
                  <td class="td-caption" align="right" width="148">
                  <font color="#FF0000">*</font>First Name:</td>
                  <td>
                  <input name="firstname" id="firstname" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right">
                  <font color="#FF0000">*</font>Last Name:</td>
                  <td>
                  <input name="lastname" id="lastname" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right">
                  <font color="#FF0000">*</font>Email Address:</td>
                  <td>
                  <input name="email" id="email" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right">Zip Code:</td>
                  <td>
                  <input name="zipcode" id="zipcode" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right">Phone No:</td>
                  <td>
                  <input name="phone" id="phone" size="30" type="text"></td>
               </tr>
               <tr>
                  <td class="td-caption" align="right" valign="top">
                  <font color="#FF0000">*</font>Message:</td>
                  <td>
                  <textarea name="message" id="message" wrap="VIRTUAL" rows="4" cols="40"></textarea></td>
               </tr>
               <tr align="center">
                  <td colspan="2" id="Q" valign="top"></td>
               </tr>
               <tr>
                  <td align="right" valign="top"> </td>
                  <td>
                  <input name="Submit" value="Submit" class="button" type="submit"> 
                  <input name="Submit2" value="Reset" class="button" type="reset"></td>
               </tr>
            </table>
         </form>
         </td>
      </tr>
   </table>

Link to comment
Share on other sites

hmmm...not sure how to do that.  But, I think I'm going to give up on the PHP form and move to an alternate form solution.  Thanks to everyone for looking at the code and trying to help.  Part of the problem is my lack of knowledge about PHP & coding in general.  Probably better for me to move to a more supportable solution. Thanks again!

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.