• GoDaddy Community
  • VPS & Dedicated Servers
  • VPS & Dedicated Servers

    cancel
    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 
    New

    POST doesn't seem to work in form setup

    Hi, I'm setting up a contact form on the About page of my site. "About.php" has the form which points to a separate mailscript.php file. The problem is that I can get the form to work but not really. For example, if I set up a variable like this: $message = $_POST['senderMessage'], I get no reply at all. But if I set up the variable like this: $message = 'senderMessage', I do get a reply but the reply has "senderMessage" as the message. Any help will be greatly appreciated. Here's my code, first PHP, then HTML:

     

     

    <?php
    
    $to='bparkman@bitsong.com';
    /*$name = 'senderName';*/
    $name = $_POST['senderName'];
    /*$message = 'senderMessage';*/
    $message = $_POST['senderMessage'];
    $headers = 'From: webmaster@bitsongDev.com' . "\r\n" .
           'Reply-To: webmaster@bitsongDev.com' . "\r\n" .
    	   'X-Mailer: PHP/' . phpversion();
    
    mail($to, $name, $message, $headers);
    
    Print "Your message has been Sent";
    
    ?>
    <form id="contactForm" name="Contact Form" method="post" action="mailscript.php" class="contactForm well form-horizontal">
            <div class="form-group">
              <label class="col-md-4 control-label" for="senderName">Name</label>  
              <div class="col-md-4">
               <div class="input-group">
                <input  id="senderName" type="text" class="form-control" name="senderName">
               </div>
              </div>
            </div>
             
            <div class="form-group">
              <label class="col-md-4 control-label">E-Mail</label>  
                <div class="col-md-4">
                <div class="input-group">      
                  <input name="to" class="form-control"  type="text">
                </div>
              </div>
            </div>
            
            <div class="form-group">
              <label class="col-md-4 control-label">Message</label>
                <div class="col-md-4">
                <div class="input-group">
                  <textarea class="form-control" name="senderMessage"></textarea>
              </div>
              </div>
            </div>
            
            <div class="form-group">
              <label class="col-md-4 control-label"></label>
              <div class="col-md-4">
                <button type="submit" class="btn-bitsong-blue" >Send</button>
              </div>
             </div>         
            </form>

     

     

     

     

    2 REPLIES 2

    Re: POST doesn't seem to work in form setup

    From initial look I can't spot anything wrong.

    Try to dump the variables to see what you are getting:

    http://php.net/manual/en/function.var-dump.php

     

    i.e.

    var_dump($_GET);

    var_dump($_POST);

     

    Also, if you are using WordPress ... why not just use a plugin? I use "Contact Form to Email" plugin.

     

    New

    Re: POST doesn't seem to work in form setup

    Thanks Clickbutt,

    I did try var_dump and it looks useful, however, I decided to go with a free make-it-yourself form from

    http://www.formmail-maker.com/generator.php.  I tried both their standard PHP form and their beta jquery form.  The standard PHP form wouldn't work on GoDaddy, but the jquery form did 🙂  Thanks for your help.