Need to post a variable using this...

Posted on 2006-05-11
Last Modified: 2012-06-21
I have this code

<input name="submit" type="submit" id="submit" onClick="MM_validateForm('name','','R','telephone','','R');return document.MM_returnValue" value="Submit">
<input type="reset" name="Reset" value="Reset Form">
<input type="hidden" name="success" value="">

At the same time as me posting the data to be e-mailed i would like to post the vaviable from the e-mail form field to the next page.

Not sure why my client has it posting to a text file but they dont want that changing. It works. I just need the e-mail address to post to the success page so that i can track them.

I have the next page set up ready to accept the variable. Just need to get it from the email field to the post variable.

Very Urgent hence why i am in work v v late.

Thanks in advance.
Question by:ShaneJones
    LVL 11

    Expert Comment

    what email form field you are refering to? Can you be more clearer?
    LVL 1

    Expert Comment

    Hi ShaneJones -

    When the user submits data through a form, the variables are passed by whichever method is declared for the form. Your <input> tags should be nested inside a <form> tag. To get your variables to pass with POST, make sure your form's method attribute is set to post.

    <form method="post" action="...">

    The action attribute of your form will the link of the page you are going to. That page can pick up the variables you passed by using

    <?php echo $_POST["name"] ?>

    where name is the input name attribute from the form.


    LVL 2

    Accepted Solution

    Ok when the user presses submit you want several things to happen
    1. Validate using your MM_validateForm script
    2. pass the email address to the "success" page
    3. pass all info to the email script

    Well, this is one way to accoplish that it just would need to be tweeked with your content and page names

    1st have a page where they enter info
    <?php session_destroy(); ?>
    <form method="post" action="confirm.php">
      <input type=submit name=submit value=submit onClick="MM_validateForm">

    Then have the confirm.php page show there info and store it in session variables
    echo "is this info true?";
    echo "$info1 $info1 $info3";
    <a href="email.php" onClick="myRef ='log.php','mywin');">Correct</a>
    <a href="form1.php">Incorrect</a>

    Lastly the log.php file would apend the email address to the log you would not need to write anything to the screen so the user would see this window open.

    Well, that is one way to accomplish your needs I am sure there are many other ways.
    LVL 16

    Expert Comment

    if all above mentioned cant apply, u can save the email as a session variable in the page from which you send the email !

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now