wishfulfillment
02-06-2012, 05:59 AM
Hey:
I am finishing up developing a website, but I'm having trouble with a certain part.
Here's the site: www.socialsalesbook.com
At the bottom of every page, there is a form that one can fill out for a "Free Consultation"; however, if I fill it out and click submit, a problem arises.
I receive an email like I want, but the "your message" text isn't there, and neither is the name of the person. The only information I get is the person's name and phone number.
Additionally, I want the page to refresh and display something like, "Message sent"; but, I can't seem to figure out how to do so. Also, when someone clicks on "Your name," but doesn't type anything, the text "Your name" disappears.
I'm still pretty new to coding so any help is much appreciated.
Here's the code:
<?php
$msg = '';
if(isset($_REQUEST['submit'])){
if(($_REQUEST['name'] && $_REQUEST['email']) != '') {
$validation = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
if( !eregi ($validation,$_REQUEST['email']) ) {
$msg = "Your email address not valied.";
} else {
$to = 'contact@socialsalesbook.com';
$subject = 'A New Contact Mail.';
$message = '
<html>
<head>
<title>A New Contact Mail</title>
</head>
<body>
<table>
<tr><td> Name : </td><td>'.$_REQUEST['lname'].'</td></tr>
<tr><td> Email Address : </td><td>'.$_REQUEST['email'].'</td></tr>
<tr><td> Phone : </td><td>'.$_REQUEST['phone'].'</td></tr>
<tr><td> Message : </td><td>'.$_REQUEST['textarea3'].'</td></tr>
</table>
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$_REQUEST['email'] . "\r\n";
@mail($to, $subject, $message, $headers);
$msg = "Your request was sent successfully.";
}
} else {
$msg = "You must insert all fields.";
}
}
?>
Here's the code for the actual forms:
<h2><label>Free Consultation:</label></h2>
<form class="ftt_infoarea" action="./index.php" method="post" enctype="multipart/form-data">
<div><b><?=$msg?></b></div>
<div><input type="text" value="Your name" onfocus="this.value=(this.value=='Your name')? '' : this.value ;" name="name" /> <b>*</b></div>
<div><input type="text" value="Your e-mail address" onfocus="this.value=(this.value=='Your e-mail address')? '' : this.value ;" name="email" /> <b>*</b></div>
<div><input type="text" value="Your phone number" onfocus="this.value=(this.value=='Your phone number')? '' : this.value ;" name="phone" /> </div>
<div><textarea rows="" cols="" name="custom Message" id="awf_field-24778597" onfocus=" if (this.value == 'Your message') { this.value = ''; }"
onblur="if (this.value == '') { this.value='Your message';} " tabindex="503" name="textarea3">Your message</textarea></div>
<fieldset><input type="submit" value="" name="submit" /></fieldset>
</form>
I am finishing up developing a website, but I'm having trouble with a certain part.
Here's the site: www.socialsalesbook.com
At the bottom of every page, there is a form that one can fill out for a "Free Consultation"; however, if I fill it out and click submit, a problem arises.
I receive an email like I want, but the "your message" text isn't there, and neither is the name of the person. The only information I get is the person's name and phone number.
Additionally, I want the page to refresh and display something like, "Message sent"; but, I can't seem to figure out how to do so. Also, when someone clicks on "Your name," but doesn't type anything, the text "Your name" disappears.
I'm still pretty new to coding so any help is much appreciated.
Here's the code:
<?php
$msg = '';
if(isset($_REQUEST['submit'])){
if(($_REQUEST['name'] && $_REQUEST['email']) != '') {
$validation = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
if( !eregi ($validation,$_REQUEST['email']) ) {
$msg = "Your email address not valied.";
} else {
$to = 'contact@socialsalesbook.com';
$subject = 'A New Contact Mail.';
$message = '
<html>
<head>
<title>A New Contact Mail</title>
</head>
<body>
<table>
<tr><td> Name : </td><td>'.$_REQUEST['lname'].'</td></tr>
<tr><td> Email Address : </td><td>'.$_REQUEST['email'].'</td></tr>
<tr><td> Phone : </td><td>'.$_REQUEST['phone'].'</td></tr>
<tr><td> Message : </td><td>'.$_REQUEST['textarea3'].'</td></tr>
</table>
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$_REQUEST['email'] . "\r\n";
@mail($to, $subject, $message, $headers);
$msg = "Your request was sent successfully.";
}
} else {
$msg = "You must insert all fields.";
}
}
?>
Here's the code for the actual forms:
<h2><label>Free Consultation:</label></h2>
<form class="ftt_infoarea" action="./index.php" method="post" enctype="multipart/form-data">
<div><b><?=$msg?></b></div>
<div><input type="text" value="Your name" onfocus="this.value=(this.value=='Your name')? '' : this.value ;" name="name" /> <b>*</b></div>
<div><input type="text" value="Your e-mail address" onfocus="this.value=(this.value=='Your e-mail address')? '' : this.value ;" name="email" /> <b>*</b></div>
<div><input type="text" value="Your phone number" onfocus="this.value=(this.value=='Your phone number')? '' : this.value ;" name="phone" /> </div>
<div><textarea rows="" cols="" name="custom Message" id="awf_field-24778597" onfocus=" if (this.value == 'Your message') { this.value = ''; }"
onblur="if (this.value == '') { this.value='Your message';} " tabindex="503" name="textarea3">Your message</textarea></div>
<fieldset><input type="submit" value="" name="submit" /></fieldset>
</form>