adamriley Posted May 11, 2010 Share Posted May 11, 2010 form.html ----------------------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>* | Sumbit Form</title> <script language="JavaScript" type="text/javascript"> <!-- function ValidateForm1(theForm) { var strValue = theForm.Editbox2.value; var strFilter = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i; if (!strFilter.test(strValue)) { alert("Please enter an email address"); return false; } return true; } //--> </script> </head> <body bgcolor="#FFFFFF" text="#000000" style="scrollbar-face-color:#D4D0C8;scrollbar-arrow-color:#000000;scrollbar-3dlight-color:#D4D0C8;scrollbar-darkshadow-color:#404040;scrollbar-highlight-color:#FFFFFF;scrollbar-shadow-color:#808080;scrollbar-track-color:#D4D0C8;"> <div id="Text1" style="position:absolute;left:127px;top:13px;width:570px;height:32px;z-index:11;" align="center"> <font style="font-size:27px" color="#000000" face="Arial"><u>FootBall Game Card</u></font></div> <div id="Form1" style="position:absolute;left:20px;top:35px;width:709px;height:374px;z-index:12;" align="left"> <form name="Form1" method="POST" action="submit.php" id="Form1" onsubmit="return ValidateForm1(this)"> <input type="text" id="name" style="position:absolute;left:269px;top:31px;width:381px;font-family:Courier New;font-size:16px;z-index:0" name="Name" value="Please Enter your full name"> <div id="Text2" style="position:absolute;left:49px;top:39px;width:146px;height:16px;z-index:1;" align="left"> <font style="font-size:13px" color="#000000" face="Arial">Name</font></div> <div id="Text3" style="position:absolute;left:49px;top:86px;width:146px;height:16px;z-index:2;" align="left"> <font style="font-size:13px" color="#000000" face="Arial">Email address <b>(****)</b></font></div> <div id="Text4" style="position:absolute;left:22px;top:217px;width:664px;height:36px;z-index:3;" align="left"> <font style="font-size:16px" color="#000000" face="Arial">(****)Please note that the email address must be the one you use for paypal as this is were if you winnings if you win will be sent </font></div> <input type="text" id="Editbox2" style="position:absolute;left:268px;top:82px;width:381px;font-family:Courier New;font-size:16px;z-index:4" name="Email" value="E.g (Pay pal Email address)"> <input type="text" id="Editbox3" style="position:absolute;left:268px;top:130px;width:379px;font-family:Courier New;font-size:16px;z-index:5" name="Code" value="<?php echo $random_number ?>" readonly="readonly"> <div id="Text5" style="position:absolute;left:47px;top:135px;width:161px;height:16px;z-index:6;" align="left"> <font style="font-size:13px" color="#000000" face="Arial">Your Random code <b>(*)</b></font></div> <div id="Text6" style="position:absolute;left:20px;top:271px;width:664px;height:36px;z-index:7;" align="left"> <font style="font-size:16px" color="#000000" face="Arial">(*)You should keep this safe as this will make sure we are talking to the right person<br> 2. If you forget this code we reserve the right to refuse payment upon winning!</font></div> <input type="submit" id="Button1" name="Button1" value="By submiting you aggree to tos and the notes above" style="position:absolute;left:26px;top:328px;width:616px;height:24px;background-color:#D4D0C8;font-family:Arial;font-size:13px;z-index:8"> <input type="text" id="Editbox4" style="position:absolute;left:266px;top:175px;width:376px;font-family:Courier New;font-size:16px;z-index:9" name="Spot" value="<?php echo $_SESSION['dir'] ?>" readonly="readonly"> <div id="Text7" style="position:absolute;left:50px;top:181px;width:150px;height:17px;z-index:10;" align="left"> <font style="font-size:15px" color="#000000" face="Arial">Team your picking</font></div> </form> </div> </body> </html> ------------------------------------------------------------------------------ submit.php ----------------------------------------------------------------------------- <?php error_reporting(E_ALL); if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) @date_default_timezone_set(@date_default_timezone_get()); session_start(); // check to make sure there is a session if(!isset($_SESSION['dir'])){ echo "Please contact webmaster as soon as posible"; die(); } else { } $Name = $_POST['Name']; // get the name from the form $Email = $_POST['Email']; // get the email from the form $code = $_POST['Code']; // Get the secrity code $dir = $_SESSION['dir']; // Get who they have picked $file = $_SESSION['dir']; // Get the dir $Time = date('h.i.s A'); // get the time $Date = date('l jS \of F Y'); // get the date $pfile = fopen("places/$dir.txt","w"); fwrite($pfile, "\r\n$Name:$Email:$code:$Date:$Time"); // header('Location: http://localhost/Game/red.php?$dir'); ?> Now the form would submit using the get method but when i change it to post it gives me an error of Notice: Undefined index: Name in C:\xampp\htdocs\Game\submit.php on line 14 Notice: Undefined index: Email in C:\xampp\htdocs\Game\submit.php on line 15 Notice: Undefined index: Code in C:\xampp\htdocs\Game\submit.php on line 16 Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2010 Share Posted May 11, 2010 Did you refresh the form page in your browser so that the change in form was in effect? Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056547 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 yes i have done :| Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056550 Share on other sites More sharing options...
kenrbnsn Posted May 11, 2010 Share Posted May 11, 2010 Put <?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?> after the "session_start();" line in submit.php to see what is being passed to your script from the form. BTW, I put your code on my local server and it works fine. Ken Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056583 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 I get Array ( ) Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056586 Share on other sites More sharing options...
kenrbnsn Posted May 11, 2010 Share Posted May 11, 2010 If you get that, the form isn't using the POST method. Do a show source on your browser when you have the form displayed to verify that you're using the file you think you're using. Ken Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056589 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 in google chrome i get this in the source code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Foot Ball Game Card | Sumbit Form</title> <script language="JavaScript" type="text/javascript"> <!-- function ValidateForm1(theForm) { var strValue = theForm.Editbox2.value; var strFilter = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i; if (!strFilter.test(strValue)) { alert("Please enter an email address"); return false; } return true; } //--> </script> </head> <body bgcolor="#FFFFFF" text="#000000" style="scrollbar-face-color:#D4D0C8;scrollbar-arrow-color:#000000;scrollbar-3dlight-color:#D4D0C8;scrollbar-darkshadow-color:#404040;scrollbar-highlight-color:#FFFFFF;scrollbar-shadow-color:#808080;scrollbar-track-color:#D4D0C8;"> <div id="Text1" style="position:absolute;left:127px;top:13px;width:570px;height:32px;z-index:11;" align="center"> <font style="font-size:27px" color="#000000" face="Arial"><u>FootBall Game Card</u></font></div> <div id="Form1" style="position:absolute;left:20px;top:35px;width:709px;height:374px;z-index:12;" align="left"> <form name="Form1" method="POST" action="submit.php" id="Form1" onsubmit="return ValidateForm1(this)"> <input type="text" id="name" style="position:absolute;left:269px;top:31px;width:381px;font-family:Courier New;font-size:16px;z-index:0" name="Name" value="Please Enter your full name"> <div id="Text2" style="position:absolute;left:49px;top:39px;width:146px;height:16px;z-index:1;" align="left"> <font style="font-size:13px" color="#000000" face="Arial">Name</font></div> <div id="Text3" style="position:absolute;left:49px;top:86px;width:146px;height:16px;z-index:2;" align="left"> <font style="font-size:13px" color="#000000" face="Arial">Email address <b>(****)</b></font></div> <div id="Text4" style="position:absolute;left:22px;top:217px;width:664px;height:36px;z-index:3;" align="left"> <font style="font-size:16px" color="#000000" face="Arial">(****)Please note that the email address must be the one you use for paypal as this is were if you winnings if you win will be sent </font></div> <input type="text" id="Editbox2" style="position:absolute;left:268px;top:82px;width:381px;font-family:Courier New;font-size:16px;z-index:4" name="Email" value="E.g (Pay pal Email address)"> <input type="text" id="Editbox3" style="position:absolute;left:268px;top:130px;width:379px;font-family:Courier New;font-size:16px;z-index:5" name="Code" value="6812" readonly="readonly"> <div id="Text5" style="position:absolute;left:47px;top:135px;width:161px;height:16px;z-index:6;" align="left"> <font style="font-size:13px" color="#000000" face="Arial">Your Random code <b>(*)</b></font></div> <div id="Text6" style="position:absolute;left:20px;top:271px;width:664px;height:36px;z-index:7;" align="left"> <font style="font-size:16px" color="#000000" face="Arial">(*)You should keep this safe as this will make sure we are talking to the right person<br> 2. If you forget this code we reserve the right to refuse payment upon winning!</font></div> <input type="submit" id="Button1" name="Button1" value="By submiting you aggree to tos and the notes above" style="position:absolute;left:26px;top:328px;width:616px;height:24px;background-color:#D4D0C8;font-family:Arial;font-size:13px;z-index:8"> <input type="text" id="Editbox4" style="position:absolute;left:266px;top:175px;width:376px;font-family:Courier New;font-size:16px;z-index:9" name="Spot" value="Stockport" readonly="readonly"> <div id="Text7" style="position:absolute;left:50px;top:181px;width:150px;height:17px;z-index:10;" align="left"> <font style="font-size:15px" color="#000000" face="Arial">Team your picking</font></div> </form> </div> </body> </html> which uses "POST" Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056597 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 would the php bit of the file make a difference? <?php session_start(); error_reporting(E_ALL); srand ((double) microtime( )*1000000); $random_number = rand(0,10000); if(isset($_SESSION['dir'])){ // Show the form require($_SERVER["DOCUMENT_ROOT"]."/Game/includes/Form.html"); } else { echo "Please contact webmaster as soon as posible due there being no session"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056598 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 Hi it must be a bug with google chrome because firefox works and so does i.e 8 Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056610 Share on other sites More sharing options...
kenrbnsn Posted May 11, 2010 Share Posted May 11, 2010 put this <?php echo '<pre>$_GET:' . print_r($_GET,true) . '</pre>'; echo '<pre>$_SERVER: . print_r($_SERVER,true) . '</pre>'; ?> after the dump of $_POST. In the $_SERVER dump, look for the value of $_SERVER['REQUEST_METHOD'] and post it. Also, is there a URL we could go to in order to test your code? Note: I tested with Chrome and your code worked fine there. Did you clear your cache in Chrome? Ken Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056612 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 The script is now printing them but you used "$_GET" But the form is post ??? Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056622 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 and there no other things on the screen "In the $_SERVER dump, look for the value of $_SERVER['REQUEST_METHOD'] and post it." but if i echo $_SERVER['REQUEST_METHOD'] i get POST Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056626 Share on other sites More sharing options...
kenrbnsn Posted May 11, 2010 Share Posted May 11, 2010 I missed typed: <?php echo '<pre>$_SERVER: . print_r($_SERVER,true) . '</pre>'; ?> should be <?php echo '<pre>$_SERVER:' . print_r($_SERVER,true) . '</pre>'; ?> Did you clear the cache in Chrome. I've noticed that Chrome has a nasty habit of showing one thing via show source and using an old copy in its cache. Ken Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056634 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 No need for comment used the wrong one Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056640 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 i get "POST" Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056647 Share on other sites More sharing options...
adamriley Posted May 11, 2010 Author Share Posted May 11, 2010 Fixed !!!! Quote Link to comment https://forums.phpfreaks.com/topic/201378-form-not-working-working-with-_get-but-not-_post/#findComment-1056649 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.