PDA

View Full Version : I'm having trouble submitting all field values simultaneously to an email id.


srijan.kuls
08-31-2013, 02:56 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Feedback Form</title>
</head>
<body>
<h1>Send Us Your Feedback!</h1>
<form action="send_mail.php" method="post" enctype="multipart/form-data">
<table>
<tr>
<td width="120">Name</td>
<td width="317"><label>
<input type="text" name="name" id="name" />
</label></td>
</tr>
<tr>
<td>Mob No</td>
<td><label>
<input type="text" name="mobile" id="mobile" />
</label></td>
</tr>
<tr>
<td>Email Adress:</td>
<td><input type="text" name="email_address" value="" maxlength="100" /></td>
</tr>
<tr>
<td>attach cv</td>
<td><label>
<input type="file" name="cv" id="cv" />
</label></td>
</tr>
<tr>
<td>Comments:</td>
<td>
<textarea rows="10" cols="50" name="comments"></textarea></td>
</tr>
<tr><td>&nbsp;</td>
<td>
<input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>














<?php
/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = "jobs@rtconsultants.in";

/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page ="post_resume.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";

/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$name = $_REQUEST['name'] ;
$mobile = $_REQUEST['mobile'] ;
$email_address = $_REQUEST['email_address'] ;
$cv = $_REQUEST['cv'] ;
$comments = $_REQUEST['comments'] ;

/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}

// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}

// If the form fields are empty, redirect to the error page.
elseif (empty($email_address) || empty($comments)) {
header( "Location: $error_page" );
}

// If email injection is detected, redirect to the error page.
elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}

// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail( "$webmaster_email", "Feedback Form Results",
$comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}
?>

edbr
09-01-2013, 04:07 AM
Add the strings. You only have $comment being mailed

srijan.kuls
09-01-2013, 06:37 AM
Add the strings. You only have $comment being mailed

Thanks but i'm a designer and m not into that coding thing.. so it would be highly appreciable if you can make it more clear.

edbr
09-01-2013, 08:05 AM
$name = $_REQUEST['name'] ;
$mobile = $_REQUEST['mobile'] ;
$email_address = $_REQUEST['email_address'] ;
$cv = $_REQUEST['cv'] ;
$comments = $_REQUEST['comments'] ;
these are your form fields so you have to create a string opr an array, ie. $message, collecting them all, then send them. however i it looks like one is an attachment so you might need help or ad different script.
There are some tutorials on this forum and i think there maybe one that would help you

srijan.kuls
09-01-2013, 05:53 PM
thanks a lot sir