Jump to content

Contact Form Redirect to seperate Sites


cow1787

Recommended Posts

So I have a contact form on my website that I got from some tutorial site (I think, it's been a while). And it works well. You enter your Name, Email, Subject, and Message. When you send, it'll send to my email. After it sends the page is redirected to my homepage.

 

Contact Page

http://www.marklemmons.com/contact.html

 

It's got a process.php that has the actual 'contact email server, etc' code in it, but I don't know php at all, that's why I'm here.  ;D  (Will post process.php code at end)

 

!!!!!

 

So here's my problem. I just set up a mobile site with a contact page as well. And I want this same form on there so you can email me from your mobile device

 

Mobile Contact Page

http://mobile.marklemmons.com/contact.html

 

So Now I have two forms, and they both work. (surprisingly...) But I want it to redirect you back to the mobile page if you sent the form From the mobile page.  And it'll send you back to the regular page if you sent the form From the regular page.  Right now it sends you back to the regular page no matter what.  I'm assuming there's some kind of  "if from mobile site, then go back to mobile site.  else if from regular site, go back to regular site" but I'm not quite sure how to do it.

 

 

<?
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message=$_POST['message'];
$send = $_POST['Send'];

if ($send == "Yes") {

//Mail the comment

/* Specify your SMTP Server, Port and Valid From Address */
ini_set("SMTP","mail.marklemmons.com");
ini_set("smtp_port","25");
ini_set("sendmail_from", "mark@marklemmons.com");

//Specify where you want them email to be sent
$to = 'mark@marklemmons.com';
$message = "Name: ".$name."\n Email: ".$email."\n Subject:".$subject."\n Message: ".$message;
$headers = 'From: '.$email. "\r\n" .
'Reply-To: '.$email. "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

header("Location: http://www.marklemmons.com/");
}
else {

echo "you don't need to access this page directly";

}
?>

Link to comment
Share on other sites

Thanks for helping. New Code with the changes at the end...

 

 

Except I get an error instead of a redirect to my page. "Parse error: syntax error, unexpected ':' in /home/markl7/public_html/process.php on line 26"

 

Line 26 is "if($_SERVER['HTTP_HOST'] == http://www.marklemmons.com)"

 

<?
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message=$_POST['message'];
$send = $_POST['Send'];

if ($send == "Yes") {

//Mail the comment

/* Specify your SMTP Server, Port and Valid From Address */
ini_set("SMTP","mail.marklemmons.com");
ini_set("smtp_port","25");
ini_set("sendmail_from", "mark@marklemmons.com");

//Specify where you want them email to be sent
$to = 'mark@marklemmons.com';
$message = "Name: ".$name."\n Email: ".$email."\n Subject:".$subject."\n Message: ".$message;
$headers = 'From: '.$email. "\r\n" .
'Reply-To: '.$email. "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

if($_SERVER['HTTP_HOST'] == http://www.marklemmons.com)
{
//code here
header("Location: http://www.marklemmomns.com")
}
if($_SERVER['HTTP_HOST'] == http://mobile.marklemmons.com)
{
//code here
header("Location: http://mobile.marklemmons.com")
}
else {

echo "you don't need to access this page directly";

}
?>

 

 

Link to comment
Share on other sites

Here's the updated code. (see bottom)  With it like this, I get another error...

 

Parse error: syntax error, unexpected T_ELSE in /home/markl7/public_html/process.php on line 36

 

So I took out the code at the end as I'm not really sure what it's for. Was in the tutorial. Do I need it? What's it do?

 

else {

echo "you don't need to access this page directly";

}

 

and then I got

 

Parse error: syntax error, unexpected $end in /home/markl7/public_html/process.php on line 37

 

I did however get it to somewhat work. I left an extra "}" at the end before ?> and it went through. except on both forms (regular and mobile) it goes back to the mobile page.

 

 

<?
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message=$_POST['message'];
$send = $_POST['Send'];

if ($send == "Yes") {

//Mail the comment

/* Specify your SMTP Server, Port and Valid From Address */
ini_set("SMTP","mail.marklemmons.com");
ini_set("smtp_port","25");
ini_set("sendmail_from", "mark@marklemmons.com");

//Specify where you want them email to be sent
$to = 'mark@marklemmons.com';
$message = "Name: ".$name."\n Email: ".$email."\n Subject:".$subject."\n Message: ".$message;
$headers = 'From: '.$email. "\r\n" .
'Reply-To: '.$email. "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

if($_SERVER['HTTP_HOST'] == "http://www.marklemmons.com");
{
//code here
header("Location: http://www.marklemmomns.com");
}
if($_SERVER['HTTP_HOST'] == "http://mobile.marklemmons.com");
{
//code here
header("Location: http://mobile.marklemmons.com");
}
else {

echo "you don't need to access this page directly";

}
?>

Link to comment
Share on other sites

like this?

 

echo $_SERVER['HTTP_HOST']; == "http://www.marklemmons.com");
{
//code here
header("Location: http://www.marklemmomns.com");
}
echo $_SERVER['HTTP_HOST']; == "http://mobile.marklemmons.com");
{
//code here
header("Location: http://mobile.marklemmons.com");
}
else {

echo "you don't need to access this page directly";

}

 

That gives me

 

"Parse error: syntax error, unexpected T_IS_EQUAL in /home/markl7/public_html/process.php on line 28"

 

 

Link to comment
Share on other sites

Placed it at the top.Uploaded it, then went to it

 

And again I got

 

Parse error: syntax error, unexpected T_ELSE in /home/markl7/public_html/process.php on line 40

 

 

<?
echo $_SERVER['HTTP_HOST'];

$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message=$_POST['message'];
$send = $_POST['Send'];

if ($send == "Yes") {

//Mail the comment

/* Specify your SMTP Server, Port and Valid From Address */
ini_set("SMTP","mail.marklemmons.com");
ini_set("smtp_port","25");
ini_set("sendmail_from", "mark@marklemmons.com");

//Specify where you want them email to be sent
$to = 'mark@marklemmons.com';
$message = "Name: ".$name."\n Email: ".$email."\n Subject:".$subject."\n Message: ".$message;
$headers = 'From: '.$email. "\r\n" .
'Reply-To: '.$email. "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);



if($_SERVER['HTTP_HOST'] == "http://www.marklemmons.com");
{
//code here
header("Location: http://www.marklemmomns.com");
}
if($_SERVER['HTTP_HOST'] == "http://mobile.marklemmons.com");
{
//code here
header("Location: http://mobile.marklemmons.com");
}
else {

echo "you don't need to access this page directly";

}
?>

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.