Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-06-2012, 05:59 AM   PM User | #1
wishfulfillment
New to the CF scene

 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
wishfulfillment is an unknown quantity at this point
Problem with Filling Out Form HTML/CSS

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

Code:
<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>
wishfulfillment is offline   Reply With Quote
Old 02-06-2012, 06:28 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Code:
<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>
Code:
<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.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 02-06-2012, 09:11 PM   PM User | #3
wishfulfillment
New to the CF scene

 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
wishfulfillment is an unknown quantity at this point
@abduraooft

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?
wishfulfillment is offline   Reply With Quote
Old 02-07-2012, 04:55 AM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
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
PHP Code:
if(isset($msg))
echo 
$msg
Quote:
I stop the text "Your name" from disappearing when someone clicks on it?
See http://www.codingforums.com/showthread.php?t=131094
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Tags
coding, form, forms

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:55 PM.


Advertisement
Log in to turn off these ads.