View Full Version : Problem with Filling Out Form HTML/CSS

02-06-2012, 05:59 AM

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:

$msg = '';
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 = '
<title>A New Contact Mail</title>
<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>

$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><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>

02-06-2012, 06:28 AM
<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>

<input type="text" value="Your name" name="name" />
<textarea rows="" cols="" name="custom Message"
Any clues?

PS: You can't have space in the name of an element.

02-06-2012, 09:11 PM

Awesome, thanks for your reply.

I changed: $_REQUEST['lname'] to $_REQUEST['name'],
$_REQUEST['textarea3'] to $_REQUEST['text'], and
name="custom Message" to name="text"

When I did a test email, I was able to get the name, email, phone, and message successfully; but, that still leaves a problem.

When someone submits their message, it doesn't give any indication that their message was sent and just refreshes the page. How do I insert a little box or indicator that tells the person that they sent a message? Additionally, how do I stop the text "Your name" from disappearing when someone clicks on it?

02-07-2012, 04:55 AM
How do I insert a little box or indicator that tells the person that they sent a message?
Add the following at the top of your form

echo $msg;

I stop the text "Your name" from disappearing when someone clicks on it? See http://www.codingforums.com/showthread.php?t=131094

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum