www.webdeveloper.com
Results 1 to 7 of 7

Thread: PHP form; why does the php form submit onload

  1. #1
    Join Date
    Jan 2010
    Location
    Atlanta,GA
    Posts
    53

    PHP form; why does the php form submit onload

    the form is submitting on page load, instead of when the submit button is clicked. How do I stop this?

    CODE :
    if(isset($_POST['my_submit'])) { //IF FORM WAS SUBMITTED
    if($_POST['realname'] == '' ) {
    $error_name = 'Please enter your name';
    $hasError = true;
    }
    elseif($_POST['email'] == '' || validate_emailaddress($_POST['email'])==false) {
    $error_email = 'Please enter a valid email address';
    $hasError = true;
    }
    elseif($_POST['comments'] == '' ) {
    $error_message = 'Please enter a message';
    $hasError = true;
    }else {
    $hasError = false;
    }
    }

    if ($hasError == false) {

    $mailTo = 'jason@jcs-productions.com';
    $header = 'from:'.$_POST['realname'].'<'.$_POST['email'].'>';
    $subject = 'Contact Form Submission, '.date('l\, F jS h:i:s A');
    $message = $_POST['comments'];

    if(mail($mailTo,$subject,$message,$header)) {
    $msg_notify = '<h5>Your Message has been Sent!</h5><p>Thank You</p>';
    $_POST = '';
    $_POST['realname'] ='';
    $_POST['email']='';
    $_POST['comments']='';
    //header('Refresh: 3; url="http://beta.jcs-productions.com/contact.php"');
    } else {
    $msg_notify = '<h5>Your have failed in messages you have!</h5>';
    }
    }

    Help I need, young padawan.

  2. #2
    Join Date
    Jan 2010
    Location
    Atlanta,GA
    Posts
    53

    btw it is posting as post="$_SERVER['PHP_SELF']

    12

  3. #3
    Join Date
    Jan 2009
    Posts
    3,346
    Is your form being loaded by the submission of another form with a field of "submit" perhaps?

  4. #4
    Join Date
    Jan 2010
    Location
    Atlanta,GA
    Posts
    53
    nope

  5. #5
    Join Date
    Jan 2010
    Location
    Atlanta,GA
    Posts
    53
    only one form on page

  6. #6
    Join Date
    Jan 2009
    Posts
    3,346
    Is that all the code? I don't see any html form code there at all...

  7. #7
    Join Date
    Jan 2010
    Location
    Atlanta,GA
    Posts
    53
    i figured it out thanks. i did not have the mailto() inside the isset(post) if statement

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles