Link to home
Start Free TrialLog in
Avatar of wraithlord
wraithlord

asked on

Simple form not working after upgrading to php5

I have this very simple contact form on one of my sites and after upgrading the servers to php5 they do not work anymore. I have attached the code. Thank you in advance.

<?php
  if ($REQUEST_METHOD == "POST") {
  
 
	$comments = ($comments);
	$from = ($email);
	$sendto = "user@sbcglobal.net";
	$subject = "Feed Back From You Website";
	$message = "$comments";
	
	mail($sendto, $subject, $message, $from); 
	header("Location: index.htm"); 	
	}
	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Site Name</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
 
 
</head>
 
<body>
 
<div id="header">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="200" height="68" align="center" bgcolor="#F68B1F"><img src="images/home_logo.gif" width="191" height="29"></td>
      <td width="7" bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="middle" bgcolor="#000000"><img src="images/indications_logo.gif" alt="Indications" width="191" height="29"></td>
      <td align="right" valign="middle" bgcolor="#000000"><img src="images/address.gif" alt="Address" width="200" height="68"></td>
    </tr>
  </table>
</div>
<div id="nav"><a href="index.htm" target="_self" class="nav">Home</a> <a href="resume.htm" target="_self" class="nav">BIO</a> <a href="index.htm" target="_self" class="nav">Portfolio </a><a href="contact.php" target="_self" class="nav">Contact </a></div>
<div id="content">
  <form action="<?php echo("$script_name"); ?>" method="post">
    Your Name:<br>
  <input name="name" type="text" id="name" style="width:200px; height:20px; border-width:1px; border-style:solid; border-color:#575757; background-color:#D0D8DA ">
  <br>
  <img src="images/spacer.gif" height="15	px"><br>
    Email:<br>
  <input name="email" type="text" id="email" style="width:200px; height:20px; border-width:1px; border-style:solid; border-color:#575757; background-color:#D0D8DA ">
  <br>
  <img src="images/spacer.gif" height="15px"><br>
    Comments:<br>
  <textarea name="comments" id="comments" style="width:200px; height:150px; border-width:1px; overflow:auto; border-style:solid; border-color:#575757; background-color:#D0D8DA "></textarea>
  <br>
  <input name="image" type="image" src="images/reset.gif">
    <input name="image" type="image" style="margin-left:15px " src="images/submit.gif">
  
  </form>
</div>
</body>
</html>

Open in new window

Avatar of fosiul01
fosiul01
Flag of United Kingdom of Great Britain and Northern Ireland image

instead of $REQUEST_METHOD == "POST")
use this

if($_POST['submit'])

hope it will work
and also
what is in here

<form action="<?php echo("$script_name"); ?>" method="post">

in $script_name ??
and also , i dont know the bellow code will work or not .

<input name="image" type="image" src="images/reset.gif">
    <input name="image" type="image" style="margin-left:15px " src="images/submit.gif">

i always use bellow code as a submit button
 

<td><input type="submit" name="submit" value="Login!"></td>
Avatar of wraithlord
wraithlord

ASKER

This did not fix it.
This did not fix it.
Have you tryed all of them ??

and also

<form action="<?php echo("$script_name"); ?>" method="post">

what is in  $script_name ?? ??
yes, I tried them all and I changed  <?php echo("$script_name"); ?>" method="post"> to contact.php" method="post"> so it just refreshes the page. <?php echo("$script_name"); ?> just refreshes the page
this form worked fine on php4
wait i will sent you edited code 10 min
yes because you need to capture the data after doing post
wait i am sending you
Try this code
<?php
 
 
        $comments = $_POST["comments"];  /* you need to caputre comments by using $_POST[ ]  */
		
        $from = $_POST["email"];
        
		$sendto = "user@sbcglobal.net";
        $subject = "Feed Back From You Website";
        $message = "$comments";
        
        mail($sendto, $subject, $message, $from); 
        header("Location: index.htm");  
        
        
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Site Name</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
 
 
</head>
 
<body>
 
<div id="header">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="200" height="68" align="center" bgcolor="#F68B1F"><img src="images/home_logo.gif" width="191" height="29"></td>
      <td width="7" bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="middle" bgcolor="#000000"><img src="images/indications_logo.gif" alt="Indications" width="191" height="29"></td>
      <td align="right" valign="middle" bgcolor="#000000"><img src="images/address.gif" alt="Address" width="200" height="68"></td>
    </tr>
  </table>
</div>
<div id="nav"><a href="index.htm" target="_self" class="nav">Home</a> <a href="resume.htm" target="_self" class="nav">BIO</a> <a href="index.htm" target="_self" class="nav">Portfolio </a><a href="contact.php" target="_self" class="nav">Contact </a></div>
<div id="content">
  <form method="post" action="<?php echo $PHP_SELF;?>">
    Your Name:<br>
  <input name="name" type="text" id="name" style="width:200px; height:20px; border-width:1px; border-style:solid; border-color:#575757; background-color:#D0D8DA ">
  <br>
  <img src="images/spacer.gif" height="15       px"><br>
    Email:<br>
  <input name="email" type="text" id="email" style="width:200px; height:20px; border-width:1px; border-style:solid; border-color:#575757; background-color:#D0D8DA ">
  <br>
  <img src="images/spacer.gif" height="15px"><br>
    Comments:<br>
  <textarea name="comments" id="comments" style="width:200px; height:150px; border-width:1px; overflow:auto; border-style:solid; border-color:#575757; background-color:#D0D8DA "></textarea>
  <br>
 <input type="submit" value="submit" name="submit">
  
  </form>
</div>
</body>
</htm

Open in new window

the code above just processes the form and sends the email. the problem it that it never lets me put in the information it just quickly sends me a blank email and the redirects
shouldn't there be a "if post" in there
 
ASKER CERTIFIED SOLUTION
Avatar of fosiul01
fosiul01
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great fast solution!!! Perfect!!!