Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @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?

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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
    I stop the text "Your name" from disappearing when someone clicks on it?
    See Making a Initial Text Value Vanish one selected
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •