Results 1 to 2 of 2

Thread: Problem getting a css php mail form working form hiddne div

  1. #1
    Join Date
    Sep 2009
    Thanked 0 Times in 0 Posts

    Question Problem getting a css php mail form working form hiddne div


    I have a website written using php and css. On the left hand side is my menu, and all the content loads in to a div called "content" using ajax. (no reload).

    However i have a feedback form that loads into a div on another layer. That seems to work fine. The probelem is when i try to send it using php. It reloads the index page, and doesn;t send the email. if i load the contact form directly, then it works fine. i really dont know what i'm doing wrong. I have spent the last 4 days working on this, can i have completely run out of ideas.

    if(isset($_POST['send'])) //check if send was clicked
    //form processor
    $to = $_POST['to'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $phone = $_POST['phone'];
    $name = $_POST['name'];
    $message = $_POST['message']; //YOU NEED TO DECLARE FORM VAIRBALES for SECURITY!!
    $sendmail = mail($to, $subject, $phone, $message, $name); //mail function - mail(to, subject, message);
    if($sendmail == true) // checks if mail function worked
    echo"it worked!";
    echo "Error sending message";
    else // if form was not processed
    <form id="form2" method="post" action="" target="_self">
    <h3><span>Contact Us</span></h3>
    			<fieldset><legend>Contact form</legend>
    				<p class="first">
    					<label for="name">Name</label>
    					<input type="text" name="name" id="name" size="30" />
    					<label for="email">Email</label>
    					<input type="text" name="email" id="email" size="30" />
    					<label for="web">Phone No.</label>
    					<input type="text" name="phone" id="phone" size="30" />
    					<label for="message">Message</label>
    					<textarea name="message" id="message" cols="30" rows="10"></textarea>
    				<input type="hidden" name="subject" value="mentoring">
    				<input type="hidden" name="to" value="">
    				<p class="submit"><button type="submit" name="send" value="send">Send</button></p>		
    <? } ?>

    Thanks in advance.
    Last edited by johnbasil; 09-18-2009 at 01:20 PM.

  2. #2
    Join Date
    Sep 2008
    Seattle, WA
    Thanked 11 Times in 11 Posts


    I would assume you'd need to have an action populated:

    action="<?php echo $_SERVER['PHP_SELF']; ?>"

    Otherwise the form doesn't have any way to parse the data.


Posting Permissions

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