Need to post a variable using this...

Posted on 2006-05-11
Medium Priority
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="http://www.venueteam.co.uk/venue-team-online-enquiry-success.html">

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

ID: 16661244
what email form field you are refering to? Can you be more clearer?

Expert Comment

ID: 16661815
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.



Accepted Solution

randy_stuart earned 2000 total points
ID: 16661890
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 = window.open('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

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

755 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