www.webdeveloper.com
Results 1 to 7 of 7

Thread: form processing help needed

  1. #1
    Join Date
    Jul 2003
    Location
    New Orleans
    Posts
    23

    form processing help needed

    I have written a javascript code to validate my form, but when studying forms I realize that I must post the information to a php file to be processed.

    here's the action of the form submit

    PHP Code:
    <form action="processloan.php" onsubmit="return checkdata()" name="form1" method="post"

    "checkdata" is a javascript cxommand that validates the form.
    then here is the code attached to the button

    PHP Code:
    <input type="submit" value="Submit" name="submit" onClick="javascript:document.form1.Action.value='1'"

    what I don't understand is wether or not the javascript action is performed before or after the info is sent to the PHP file. And what exactly do I need to do in "processloan.php" to make the form work?

    Any help is appreciated

    thanks

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    First of all, get rid of the onclick in your submit button. You don't need that. Next, the javascript will run when you submit the form. The function checkdata() will retrun either true or false. If it returns true, the form will be submitted to the PHP script specified in your action, if it returns false, the form will not be submitted...

    Here is a PHP script I wrote to process forms, if that will help you out. http://forums.webdeveloper.com/showt...9543#post48748

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Jul 2003
    Location
    New Orleans
    Posts
    23

    I followed your instructios but it doesn't use the javascript

    You can view the code at the following url:

    http://www.caillouette.com/SIMC3b/HTML/apply.html


    the code for the form begins like this:


    PHP Code:
     <form action="process.php" onsubmit="return checkdata()" name="form1" method="post"

    And on the submit button I have this code:

    PHP Code:
    <input type="submit" value="Submit" name="submit" onClick="javascript:document.form1.Action.value='1'"
    the javascript validation isn't working and I get the following error
    PHP Code:
    WarningCannot modify header information headers already sent by (output started at /usr/home/web/users/a0017855/html/SIMC3b/HTML/process.php:2in /usr/home/web/users/a0017855/html/SIMC3b/HTML/process.php on line 74 
    I'm using your php code to process the information. Why isn't the javascript working?

    the email comes throughwith the information just fine.

    Any advice is greatly appreciated

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Please justify having this code in your button:

    onClick="java script:document.form1.Action.value='1'"

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  5. #5
    Join Date
    Jul 2003
    Location
    New Orleans
    Posts
    23

    okay I took that bit out of my submit button but . . .

    I still get the following error:

    PHP Code:
    WarningCannot modify header information headers already sent by (output started at /usr/home/web/users/a0017855/html/SIMC3b/HTML/process.php:2in /usr/home/web/users/a0017855/html/SIMC3b/HTML/process.php on line 74 

    and my button now has the following code:
    PHP Code:
     <input type="submit" value="Submit" name="submit"
    But the Javascript isn't working.

    I enter just my first name and it sends an email to me with my first name and all the opther labels blank.

    you can view the source here:

    http://www.caillouette.com/SIMC3b/HTML/apply.html

    Thanks for the help

  6. #6
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    The header error you are getting mean you are trying to set header information after text has been sent to the browser. Perhaps you could post the code in process.php

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  7. #7
    Join Date
    Jul 2003
    Location
    New Orleans
    Posts
    23

    the code in process is . . .

    the code in process is the code from your example.

    Here it is in full:



    <?PHP


    PHP Code:
     ##################################################
    #####

    # This script is Copyright 2003, Infinity Web Design  #

    # Written by Ryan Brill - [email]ryan@infinitypages.com[/email]      #

    # All Rights Reserved - Do not remove this notice     #

     ##################################################
    #####



    ## The lines below need to be edited...



    ###################### Set up the following variables ######################

    #                                                                          #

    $to "sean@caillouette.com"#set address to send form to

    $subject "Results from your Request Info form"#set the subject line

    $headers "From: Form Mailer"#set the from address

    $forward 1# redirect? 1 : yes 

    $location "thankyou.htm"#set page to redirect to, if 1 is above

    #                                                                          #

    ##################### No need to edit below this line ######################



    ## set up the time ##



    $date date ("l, F jS, Y");

    $time date ("h:i A");



    ## mail the message ##



    $msg "Below is the result of your feedback form.  It was submitted  on $date at $time.\n\n";

        

    foreach (
    $_POST as $key => $value) {

        
    $msg .= ucfirst ($key) ." : "$value "\n";

    }



    mail($to$subject$msg$headers);

    if (
    $forward == 1) {

        
    header ("Location:$location");

    }

    else {

        echo (
    "Thank you for submitting our form. We will get back to you as soon as possible.");

    }



    ?> 
    Thanks

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