Jump to content

Recommended Posts

Hi, I know this is seriously basic stuff for most of you. I've made several websites with Swish and used the php scripts i've grabbed from the net for the contact forms, but now my main server has updated to php5 and the contact form on that website doesn't work. Can anyone give me some advice? I do not really know php, have just muddled through somehow.

 

Here's the original script that works on php4 server:

 

 

<?

if ($send=="yes") {

$to = "myemail";

$subject = "$subjectVar";

$body .= "$msgVar";

$from = "$nameVar";

$tfrom = "From: <$emailVar>";

mail($to,$subjectVar,$msgVar,$tfrom);

}

echo "&errormessage=Email has been sent&";

?>

 

 

 

and here's my attempt at updating it to php5:

<?

if ($send=="yes") {

$to = "myemail";

$subject = "$_POST['subjectVar']";

$body .= "$_POST['msgVar']";

$from = "$_POST['nameVar']";

$tfrom = "From: <$_POST['emailVar']>";

mail($to,$_POST['subjectVar'],$_POST['msgVar'],$tfrom);

}

echo "&errormessage=Email has been sent&";

?>

 

 

any help greatly apprecated!

Link to comment
https://forums.phpfreaks.com/topic/189055-contact-form-php5-help/
Share on other sites

Hi, I know this is seriously basic stuff for most of you. I've made several websites with Swish and used the php scripts i've grabbed from the net for the contact forms, but now my main server has updated to php5 and the contact form on that website doesn't work. Can anyone give me some advice? I do not really know php, have just muddled through somehow.

 

Here's the original script that works on php4 server:

 

 

<?

if ($send=="yes") {

$to = "myemail";

$subject = "$subjectVar";

$body .= "$msgVar";

$from = "$nameVar";

$tfrom = "From: <$emailVar>";

mail($to,$subjectVar,$msgVar,$tfrom);

}

echo "&errormessage=Email has been sent&";

?>

 

 

 

and here's my attempt at updating it to php5:

<?

if ($send=="yes") {

$to = "myemail";

$subject = "$_POST['subjectVar']";

$body .= "$_POST['msgVar']";

$from = "$_POST['nameVar']";

$tfrom = "From: <$_POST['emailVar']>";

mail($to,$_POST['subjectVar'],$_POST['msgVar'],$tfrom);

}

echo "&errormessage=Email has been sent&";

?>

 

 

any help greatly apprecated!

 

I just tested on my debian php5 server and the first script works. It must be something else with sendmail or something.

This is what I tested with.

 

<html>
<body>
<form>
<form id='form1' name='form1' method='post' action='mailtest.php'>
          <label>Email:
          <input type='text' name='email' id='email' />
          </label>
          <input type='submit' name='submit' id='submit' value='Submit' />
</form>
</body>
</html>
<?


$send = 'yes';


if ($send=="yes") {
$to = $_POST['email'];
$subject = "test";
$body .= "test";
$from = "[email protected]";
$tfrom = "From: <[email protected]>";
mail($to,$subjectVar,$msgVar,$tfrom);
}
echo "&errormessage=Email has been sent&";
?>

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.