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 10 of 10

Thread: Testing a form

  1. #1
    Regular Coder
    Join Date
    Oct 2011
    Posts
    135
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Testing a form

    I built a form from a sample I seen. But I don't know if it's going to work. How do I test it?

    Code:
    <?php
    $action=$_REQUEST['action'];
    if ($action=="")    /* display the contact form */
        {
        ?>
        <form  action="" method="POST" enctype="multipart/form-data">
          <p>
          <input type="hidden" name="action" value="submit">
        First Name:
        <input name="first" type="text" value="" size="30"/><br>
        
        
        Last Name:
        <input name="last" type="text" value="" size="30"/><br>
         
        Company:
        <input name="company" type="text" value="" size="30"/><br>  
       
        Phone:
        <input name="phone" type="text" value="" size="30"/><br>
        
        Email:
        <input name="email" type="text" value="" size="30"/><br>  
        
        Your Website:
        <input name="your" type="text" value="" size="30"/><br>  
        
        Date Of Event:
        <input name="date" type="text" value="" size="30"/><br> 
        
        Event Theme:
        <input name="event" type="text" value="" size="30"/><br>
        
         Specifics and Location:<br>
        <textarea name="specidica" rows="7" cols="30"></textarea>
        <br>
        
        Comments:<br>
        <textarea name="comments" rows="7" cols="30"></textarea>
        <br>
        
        
        
        <input type="submit" value="Send email"/>
          </p>
        </form>
        <?php
        } 
    else                /* send the submitted data */
        {
        $first=$_REQUEST['first'];
        $last=$_REQUEST['last'];
        $company=$_REQUEST['company'];
        $phone=$_REQUEST['phone'];
        $email=$_REQUEST['email'];
        $your=$_REQUEST['your'];
        $date=$_REQUEST['date'];
        $event=$_REQUEST['event'];
       
       
        $specifics=$_REQUEST['specifics'];
        if (($name=="")||($email=="")||($specifics==""))
        
        $comments=$_REQUEST['comments'];
        if (($name=="")||($email=="")||($comments==""))
            {
            echo "All fields are required, please fill <a href=\"\">the form</a> again.";
            }
        else{        
            $from="From: $name<$email>\r\nReturn-path: $email";
            $subject="Message sent using your contact form";
            mail("louis@charismacommunications.ca", $subject, $message, $from);
            echo "Email sent!";
            }
        }  
    ?>

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,662
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    This has nothing to do with JavaScript or any JS framework. Moving to PHP.

    And to answer your question: You test it by submitting the form. Depending on what it’s supposed to do you see whether or not it works if the action that you expect to occur is or isn’t ocurring.

  • #3
    Regular Coder
    Join Date
    Oct 2011
    Posts
    135
    Thanks
    4
    Thanked 0 Times in 0 Posts
    is there any places on the net i can test drive php?

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,323
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Quote Originally Posted by Charisma View Post
    is there any places on the net i can test drive php?
    Oh wow thats deep lol.

    How about your website? If you don't have one, download a WAMP package and install it locally.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #5
    Regular Coder
    Join Date
    Oct 2011
    Posts
    135
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I tryed it as is. and I think it's when I click send. it doesn't go.

  • #6
    Regular Coder
    Join Date
    Oct 2011
    Posts
    135
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Ok. Loaded it on my website and it still does not send me the information after clicking send. I don't know how to fix it. this is the site.

    http://www.cjwebconsulting.com/newsite/events.html

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    .html isn't parsed as PHP code by default. Either use a .php page or configure the webserver to serve .html as php.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    Regular Coder
    Join Date
    Oct 2011
    Posts
    135
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Can you have a form without PHP?

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Yes you can, but this form is self posting, so therefore the script must be PHP. If you check the source on the page, you will see that the PHP code is in it which indicates that its not processing the PHP code.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #10
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,662
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    Quote Originally Posted by Charisma View Post
    Can you have a form without PHP?
    Yes, but it won’t do anything without PHP (or any other server-side script).


  •  

    Posting Permissions

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