| | |
submit and isset
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
I have this chronic problem with my php file, though I have made a lot research about the submit buttons and isset and $_POST part of the problem still persist. For you to understand and probably point out my mistakes, i have enclosed the script below:
the problem is with processing the reset and next buttons - I have tried several options and neither solves the problem.
php Syntax (Toggle Plain Text)
<?php $m = (!$m) ? date("m",mktime()) : "$m"; $y = (!$y) ? date("Y",mktime()) : "$y"; if (($_SERVER['REQUEST_METHOD'] == "POST") || ($_SERVER['Submit7'] == "Next")) { $eventdate = $_POST['eventdate']; $stime = $_POST['stime']; $location = $_POST['locate']; $mdescription = $_POST['description']; header('location:next.php'); exit(); }else if (($_SERVER['REQUEST_METHOD'] == "POST") || ($_SERVER['Submit6'] == "Reset")) { header('location: myfile.php'); exit(); } ?> <html> <table> <tr> <!-- calling the function to draw the calendar --> <td valign="top"><?php cal($_GET['m'],$_GET['y']); ?></td> <td width="25" nowrap><br /></td> <td> </td> <td> <!-- the second column of the table starts here --> <!-- --> <form name="me" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table cellpadding="0" cellspacing="0" border="0" bgcolor="#000000"><tr><td> <table cellpadding="4" cellspacing="1" border="0 "bgcolor="#FFFFFF"> <tr><td colspan="2" bgcolor="#3399FF"><font size="+1" color="#FFFFFF"><b>Request Form</b></font></td></tr> <tr><td><b>Date for Event: </b></td><td><input type="text" name="eventdate" value="" size="12"> <font size="2">dd/mm/yyyy</font></td></tr> <tr> <td><b>Start Time:</b></td> <td><input type="text" name="stime"> 24 Hour Format ie.1125 </td> </tr> <tr> <td><b>Location:</b></td> <td><input type="text" name="locate">20 Characters</td> </tr> <tr> <td><b> Description:</b></td> <td><textarea name="descrption"></textarea></td> </tr> <tr> <td colspan="2" bgcolor="#3399FF"><div align="center"> <input type="submit" name="Submit6" method="POST" value="Reset"> <input type="submit" method="post" name="Submit7" value="Next"> </td> </tr> </table></form> </table> </blockquote> </body> </html> <?php>
the problem is with processing the reset and next buttons - I have tried several options and neither solves the problem.
Last edited by peter_budo; Sep 30th, 2008 at 5:40 am. Reason: Keep It Organized - please use [code] tags
Make sure you put your code in code tags.
Would it not be better to replace the IF statement with
This will check whether the submit button has been clicked, also I don't believe $_SERVER can be used to check form fields, check http://uk3.php.net/manual/en/reserve...les.server.php.
Also, can I ask why you aren't using the reset button in HMTL?
php Syntax (Toggle Plain Text)
if (($_SERVER['REQUEST_METHOD'] == "POST") || ($_SERVER['Submit7'] == "Next")) { $eventdate = $_POST['eventdate']; $stime = $_POST['stime']; $location = $_POST['locate']; $mdescription = $_POST['description']; header('location:next.php'); exit(); }
php Syntax (Toggle Plain Text)
if (isset($_POST['Submit7'])) {
Also, can I ask why you aren't using the reset button in HMTL?
<input type="reset"> as this will clear all fields in the form. Last edited by Will Gresham; Sep 29th, 2008 at 7:16 pm.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
•
•
•
•
Make sure you put your code in code tags.
Would it not be better to replace the IF statement withphp Syntax (Toggle Plain Text)
if (($_SERVER['REQUEST_METHOD'] == "POST") || ($_SERVER['Submit7'] == "Next")) { $eventdate = $_POST['eventdate']; $stime = $_POST['stime']; $location = $_POST['locate']; $mdescription = $_POST['description']; header('location:next.php'); exit(); }
This will check whether the submit button has been clicked, also I don't believe $_SERVER can be used to check form fields, check http://uk3.php.net/manual/en/reserve...les.server.php.php Syntax (Toggle Plain Text)
if (isset($_POST['Submit7'])) {
Also, can I ask why you aren't using the reset button in HMTL?<input type="reset">as this will clear all fields in the form.
will try your options and get back ASAP
Hi Xan,
I have worked on the script after your last input and have changed the $_SERVER to:
The reset works, but when I click on the next button, it seems to function just like the reset.
I have worked on the script after your last input and have changed the $_SERVER to:
php Syntax (Toggle Plain Text)
if(isset($submit)== 'Next') { $eventdate = $_POST['eventdate']; $stime = $_POST['stime']; $location = $_POST['locate']; $mdescription = $_POST['description']; }
The reset works, but when I click on the next button, it seems to function just like the reset.
Last edited by peter_budo; Sep 30th, 2008 at 5:40 am. Reason: Keep It Organized - please use [code] tags
Not quite
$_POST['xx'] is the item to use for the if statement.
What this does is gets the value for the field in the form which is named in quotes.
You don't need anything but
All you need for the if statement is the code I posted earlier,
$_POST['xx'] is the item to use for the if statement.
What this does is gets the value for the field in the form which is named in quotes.
You don't need anything but
<input type="submit" name="Submit7" value="Next" /> for the submit button, the method=post is defined by the <form> tag.All you need for the if statement is the code I posted earlier,
if (isset($_POST['Submit7'])) { this says 'If Submit7 has been pressed, run the following code'. AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Thanks Xan, I now have an understanding of how the implementation should be, however, after several trials the next button seem only reset the page. could it be a prblem with the form tag?
1. <form name="me" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
I changed it to
2. <form name="me" method="POST" action="<? echo $PHP_SELF; ?> > and the error after submitting the next button is
Forbidden
You don't have permission to access /myclass/< on this server.
Dont you think am not doing something right?
sorry for being a pain.
1. <form name="me" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
I changed it to
2. <form name="me" method="POST" action="<? echo $PHP_SELF; ?> > and the error after submitting the next button is
Forbidden
You don't have permission to access /myclass/< on this server.
Dont you think am not doing something right?
sorry for being a pain.
I have broken up the code with the required changes as below:
Changes Here
Remove reset code
Changes Here
This should do what you want.
php Syntax (Toggle Plain Text)
<?php $m = (!$m) ? date("m",mktime()) : "$m"; $y = (!$y) ? date("Y",mktime()) : "$y";
php Syntax (Toggle Plain Text)
if (isset($_POST['Submit7']))
php Syntax (Toggle Plain Text)
{ $eventdate = $_POST['eventdate']; $stime = $_POST['stime']; $location = $_POST['locate']; $mdescription = $_POST['description']; header('location:next.php'); exit(); }
php Syntax (Toggle Plain Text)
?> <html> <table> <tr> <!-- calling the function to draw the calendar --> <td valign="top"><?php cal($_GET['m'],$_GET['y']); ?></td> <td width="25" nowrap><br /></td> <td> </td> <td> <!-- the second column of the table starts here --> <!-- --> <form name="me" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table cellpadding="0" cellspacing="0" border="0" bgcolor="#000000"><tr><td> <table cellpadding="4" cellspacing="1" border="0 "bgcolor="#FFFFFF"> <tr><td colspan="2" bgcolor="#3399FF"><font size="+1" color="#FFFFFF"><b>Request Form</b></font></td></tr> <tr><td><b>Date for Event: </b></td><td><input type="text" name="eventdate" value="" size="12"> <font size="2">dd/mm/yyyy</font></td></tr> <tr> <td><b>Start Time:</b></td> <td><input type="text" name="stime"> 24 Hour Format ie.1125 </td> </tr> <tr> <td><b>Location:</b></td> <td><input type="text" name="locate">20 Characters</td> </tr> <tr> <td><b> Description:</b></td> <td><textarea name="descrption"></textarea></td> </tr> <tr> <td colspan="2" bgcolor="#3399FF"><div align="center">
php Syntax (Toggle Plain Text)
<input type="reset" name="Submit6" value="Reset"> <input type="submit" name="Submit7" value="Next">
php Syntax (Toggle Plain Text)
</td> </tr> </table></form> </table> </blockquote> </body> </html>
This should do what you want.
Last edited by Will Gresham; Sep 29th, 2008 at 9:31 pm.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
![]() |
Similar Threads
- New CMS - Help Needed (PHP)
- submit button (PHP)
- (isset($_POST['submitted'])) not working, not sure why (PHP)
- checkboxes (PHP)
- Double Dropdown Submit ,PHP ,MYSQL (PHP)
- mysql errors, from submit.php and index.php (PHP)
- MYSQL/PHP variable check (MySQL)
- Variable Validation & MYSQL (PHP)
Other Threads in the PHP Forum
- Previous Thread: htaccess to hide directory listing!
- Next Thread: need help with dynamic PHP
| Thread Tools | Search this Thread |
apache api array basic beginner binary broken cache cakephp checkbox class cms code computing confirm cron curl customizableitems database date delete display dynamic echo email error external file files filter folder form forms forum function functions gc_maxlifetime google headmethod host howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php phpmysql problem query question radio random recursion remote script search select server sessions sms snippet source space sql syntax system table thesishelp trouble tutorial update upload url validator variable video web youtube





