form handled by function instead of page
Page 1 of 1
form handled by function instead of page
Is there a way to have a form handled by a php function within the same page as the form instead of being handled by a separate page. I have a simple mail form and when the mail is sent I would prefer an alert box to be displayed within the same page instead of having a new page loaded which displays "mail sent". Thanks for any suggestionsRe: form handled by function instead of page
<html><head>
<title>the-same-page.php</title>
</head>
<body>
<form action="the-same-page.php" method="get">
<input type="text" name="firstName" /><br />
<input type="text" name="lastName" /><br />
<input type="submit" />
</form>
First Name: <$php echo $_GET["firstName"]; ?><br />
Last Name: <$php echo $_GET["lastName"]; ?>
</body>
</html>
--
~Chris
~Chris
Re: form handled by function instead of page
1 more option if you leave form action blank it will submit to the same page by default !<form action="" method="get">
Re: form handled by function instead of page
thank you chrisf1288 and XainPro for your help. I was able to get your suggestions to work but I had to change: <$php echo $_GET["firstName"]; to: <?php echo $_GET["firstName"];unfortunately I am not able to use this method with my form because my form sends an email instead of generating html. It doesn't wait for form submission but instead sends a blank email. All the same I appreciate being able to familiarize myself with the "get" method.
Re: form handled by function instead of page
Oops, sorry about that syntax mistake.--
~Chris
~Chris
Re: form handled by function instead of page
Well i will Recommend you To Study And Learn AJAX Technique From AJAX you can send and receive data without page being refreshed.Re: form handled by function instead of page
Thank you for the tip.Re: form handled by function instead of page
chrisf1288 wrote:<html>
<head>
<title>the-same-page.php</title>
</head>
<body>
<form action="the-same-page.php" method="get">
<input type="text" name="firstName" /><br />
<input type="text" name="lastName" /><br />
<input type="submit" />
</form>
First Name: <$php echo $_GET["firstName"]; ?><br />
Last Name: <$php echo $_GET["lastName"]; ?>
</body>
</html>
Thanks for the useful info.
--------------------
oil painting for sale
Page 1 of 1