Jump to content

Php, Feedback form, sucessfull and fail pages + sending results to e-mail


scorchgid

Recommended Posts

I am making a website with a feedback form, I want the form to do certain things based on if the user enters or doesn’t enters certain field. If the user doesn’t the required field then its programmed to go to an error page, if the user does it correctly then it goes to a success page.

If success then what they entered is sent t me in an e-mail. ([email protected])

I have tried to write my own php code, with guides from the internet but it does not seem to be working. I did upload my site to the net

Could you take a look at my code and see where I’ve gone wrong.

This is the site where the form is http://www.mhchs.org.uk/gideon/Website/Feedback.html

This is the php code I used:

<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
if (!isset($_REQUEST['email'])) {header( "Location: ../website/feedback.html" );
}
elseif (empty($email) || emtpy($message)) {header( "Location: ../website/feedbacke.html" );
}
else {
mail( "[email protected]", "My Fellow EU Feedback",
 $message, "From: $fullname\n" )
"Email: $email\n"
"School: $school\n"
"School Year: $Schoolyear\n"
"How did you find out about MFE: $RA1\n"
"What did you like about the site: $CB\n"
"Difficulty of site: $RA2\n"
"Improvements: $Site better\n"
"One Word: $Feeling"	;

header( "Location: ../website/feedbacks.html" );
)
?>

 

 

This is also another code, which I tried, or rather how I want it to be, but it also failed

<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
if (!isset($_REQUEST['email'])) {header( "Location: ../website/feedback.html" );
}
elseif($fullname == ''){header( "Location: ../website/feedbacke.html" );
elseif($email == ''){header( "Location: ../website/feedbacke.html" );
elseif($Schoolyear == ''){header( "Location: ../website/feedbacke.html" );
elseif($RA1 == ''){header( "Location: ../website/feedbacke.html" );
elseif($RA2 == ''){header( "Location: ../website/feedbacke.html" );

}
else {
mail( "[email protected]", "My Fellow EU Feedback",
 $message, "From: $fullname\n" )
"Email: $email\n"
"School: $school\n"
"School Year: $Schoolyear\n"
"How did you find out about MFE: $RA1\n"
"What did you like about the site: $CB\n"
"Difficulty of site: $RA2\n"
"Improvements: $Site better\n"
"One Word: $Feeling"	;

header( "Location: ../website/feedbacks.html" );
)
?>

When I run either run I get the message

“Parse error: syntax error, unexpected '"' in E:\inetpub\vhosts\mhchs.org.uk\httpdocs\gideon\website\feedback.php on line 11”

 

Which is strange seeing as in the first one there is nothing on line 11

The second has the code

"Email: $email\n"

 

Thanks,

 

I apreicate your help

Try this

 

<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
if (!isset($_REQUEST['email'])) {header( "Location: ../website/feedback.html" );
}
elseif($fullname == '' or $email == '' or $Schoolyear == '' or $RA1 == '' or $RA2 == ''){header( "Location: ../website/feedbacke.html" );
}
else {

$to = '[email protected]';
$subject = '[email protected]';
$from = $fullname;
$message = 'Email: '.$email.'\n 
School: '.$school.'\n 
School Year: '.$Schoolyear.'\n 
How did you find out about MFE: '.$RA1.'\n
What did you like about the site: '.$CB.'\n
Difficulty of site: '.$RA2.'\n
Improvements: '.$Sitebetter.'\n
One Word: '.$Feeling;


mail($to, $subject, $message, $from)

header( "Location: ../website/feedbacks.html" );
)
?>

Try this

 

<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
if (!isset($_REQUEST['email'])) {header( "Location: ../website/feedback.html" );
}
elseif($fullname == '' or $email == '' or $Schoolyear == '' or $RA1 == '' or $RA2 == ''){header( "Location: ../website/feedbacke.html" );
}
else {

$to = '[email protected]';
$subject = '[email protected]';
$from = $fullname;
$message = 'Email: '.$email.'\n 
School: '.$school.'\n 
School Year: '.$Schoolyear.'\n 
How did you find out about MFE: '.$RA1.'\n
What did you like about the site: '.$CB.'\n
Difficulty of site: '.$RA2.'\n
Improvements: '.$Sitebetter.'\n
One Word: '.$Feeling;


mail($to, $subject, $message, $from)

header( "Location: ../website/feedbacks.html" );
)
?>

 

When all fields were entered

"Parse error: syntax error, unexpected T_STRING in E:\inetpub\vhosts\mhchs.org.uk\httpdocs\gideon\website\feedback.php on line 25"

 

When not all fields were entered:

Parse error: syntax error, unexpected T_STRING in E:\inetpub\vhosts\mhchs.org.uk\httpdocs\gideon\website\feedback.php on line 25

 

25 -

header( "Location: ../website/feedbacks.html" );

 

Unsure why, its on the site so you can try it out

 

Any ideas why it didn't work. 'E' i know referes to the USB i made the site on, but i used a relative file path, the site and its contense was moved onto the school server, but if its just one line that is buggered, then why not the other links too?.

 

I mean what i have to open up dreamweaver on the site and change the settings, I shouldn't have too, the images show and they use relative file path from the same settings. So if it didn't work they wouldn't be showing either.

Archived

This topic is now archived and is closed to further replies.

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