Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    39
    Thanks
    0
    Thanked 1 Time in 1 Post

    Form not posting to self

    Hello I have the following code
    Code:
    <?PHP
    session_start(); 
    
    include ("../includes/connect.inc");
    
    
    if (isset($_SESSION['user']))
    {
    $user = $_SESSION['user'];
    $password = $_SESSION['password'];
    }
    else
    {
    //if the username is not passed then it goes back to the login page
    	header("location: ../player_login.php");
    }
    
    if (isset($_SESSION['playernumber']))
    {
    	$ssPlayerNumber=$_SESSION['playernumber'];
    } 
    //gets the player_number from the security table
    else
    {
    	echo "session not set";
    	$checkplayernumber  = "Select player_number from security where userid = '$user' AND password = '$password'";
    	$getplayernumber = mysql_query($checkplayernumber) or die (mysql_error());
    	//$ssPlayerNumber=mysql_fetch_assoc($getplayernumber);
    	$ssPlayerNumber=mysql_fetch_array($getplayernumber['player_number']);
    
    	$_SESSION['playernumber']=$ssPlayerNumber['player_number'];
    }
    
    
    echo "Hello";
    echo $_POST['helpSubmit'];
    
    
    if (isset($_POST['helpSubmit']))
    //if (isset ($_POST['helpSubmit']))
    {
    $Friday1=$_POST['fri1']; //fri_1
    echo $Friday;
    $Friday2=$_POST['fri2']; //fri_2
    $Saturday1=$_POST['Sat_1a']; //sat_8_12_p1
    $Saturday2=$_POST['Sat_1b']; //sat_8_12_p2
    $Saturday3=$_POST['sat_2a']; //sat_12_4_p1
    $Saturday4=$_POST['Sat_2b']; //sat_12_4_p2
    $Saturday5=$_POST['Sat_4p']; //sat_4_8_p1
    $Saturday6=$_POST['sat_48p']; //sat_4_8_p2
    $Sunday1=$_POST['sun_1a']; //sun_8_1_p1
    $Sunday2=$_POST['sun_1b']; //sun_8_1_p2
    $Sunday3=$_POST['sun_16a']; //sun_1_6_p1
    $Sunday4=$_POST['Sunday16b']; //sun_1_6_p2
    
    
    $result = mysql_query("UPDATE tournament_desk_help SET fri_1='$Friday1', fri_2='$Friday2', sat_8_12_p1='$Saturday1', sat_8_12_p2='$Saturday2', sat_12_4_p1='$Saturday3', sat_12_4_p2='$Saturday4', sat_4_8_p1='$Saturday5', sat_4_8_p2='$Saturday6', sun_8_1_p1='$Sunday1', sun_8_1_p2='$Sunday2', sun_1_6_p1='$Sunday3', sun_1_6_p2='$Sunday4' WHERE help_no='3'") or die(mysql_error());  
    }
    
    //select statement from the db
    $getHelpDeskInformation = "SELECT * FROM tournament_desk_help";
    $getInformation = mysql_query($getHelpDeskInformation) or die (mysql_error());
    $row5 = mysql_fetch_array($getInformation);
    
    //setting the variables for the text boxes
    $Friday169=$row5['fri_1']; 
    $Friday269=$row5['fri_2']; 
    $Saturday1812=$row5['sat_8_12_p1']; 
    $Saturday2812=$row5['sat_8_12_p2']; 
    $Saturday1124=$row5['sat_12_4_p1'];	 
    $Saturday2124=$row5['sat_12_4_p2']; 
    $Saturday148=$row5['sat_4_8_p1'];  
    $Saturday248=$row5['sat_4_8_p2']; 
    $Sunday181=$row5['sun_8_1_p1']; 
    $Sunday281=$row5['sun_8_1_p2']; 
    $Sunday116=$row5['sun_1_6_p1'];  
    $Sunday216=$row5['sun_1_6_p2'];  
    ?>
    <head>
    <title>ATN Team Tournament - Help Desk Signup</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="../atn.css" type="text/css"></head>
    <html>
    <body bgcolor="#FFFFFF" text="#000000">
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td colspan="3"> 
          <?PHP //include ("../includes/header.html") ?>
          <?PHP //include ("../includes/util_sec.html") ?>
        </td>
      </tr>
      <tr> 
        <td width="100%" height="10" valign="top"></td>
      </tr>
    
      <tr> 
        <td width="100%" height="300" valign="top"><table width="100%" height="300" border="1" cellpadding="0" cellspacing="0">
            <tr> 
              <td width="20%">
            <?PHP //include ("../includes/main_standard.php") ?>
    		  </td>
              <td width="60%"> <div align="center"> 
                  <form name = "form1" method = "post" action="<?PHP echo $_SERVER['PHP_SELF']; ?> ">
                    <p align="center"><font size="4"><strong>2011 ATN Hit for Hope Charity 
                      Tournament - Desk Sign-Up</strong></font></p>
                    <p align="center"><strong><font size="3">Enter your name for the 
                      time you can help out, <br>
                      </font></strong><strong><font size="3">then press 'submit' to 
                      save.</font></strong></p>
                    <p align="center"><strong>If you can't work the entire time, enter the time you can work.</strong> </p>
                    <p align="center"><strong><font size="3"><br>
                    </font></strong></p>
                    <table width="95%" border="1" bgcolor="#33FF00">
                      <tr> 
                        <td width="40%"><div align="center"><strong>Time</strong></div></td>
                        <td width="60%"><div align="center"><strong>Helper</strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>Friday 6-9</strong></div></td>
                        <td width="60%"><div align="center"><strong>
    					<input name="fri1" type="text" id="fri1" value="<?PHP echo $Friday169; ?>" size="35">
                        </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>&quot;</strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                        <input name="fri2" type="text" id="fri2" value="<?PHP echo $Friday269 ?>" size="35">
                            </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>Saturday 8am-12pm </strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="Sat_1a" type="text" id="Sat_1" value="<?PHP echo $Saturday1812; ?>" size="35">
                            </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>&quot;</strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="Sat_1b" type="text" id="Sat_2" value="<?PHP echo $Saturday2812 ?>" size="35">
                            </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>Saturday 12pm-4pm </strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="sat_2a" type="text" value="<?PHP echo $Saturday1124 ?>" size="35">
                            </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>&quot;</strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="Sat_2b" type="text" value="<?PHP echo $Saturday2124 ?>" size="35">
                            </strong></div></td>
                      </tr>
    				 
    				  <tr> 
                        <td width="40%"><div align="center"><strong>Saturday 4pm-8pm </strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="Sat_4p" type="text" value="<?PHP echo $Saturday148 ?>" size="35">
                            </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>&quot; 
                            </strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="sat_48p" type="text" value="<?PHP echo $Saturday248 ?>" size="35">
                            </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>Sunday 8am-1pm </strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="sun_1a" type="text" value="<?PHP echo $Sunday181 ?>" size="35">
                            </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>&quot;</strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="sun_1b" type="text" id="sun_1b" value="<?PHP echo $Sunday281 ?>" size="35">
                            </strong></div></td>
                      </tr>
                      <tr> 
                        <td width="40%"><div align="center"><strong>Sunday 1pm-6pm </strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="sun_16a" id="sun_16a" type="text" value="<?PHP echo $Sunday116 ?>" size="35">
                            </strong></div></td>
                      </tr>
    				   <tr> 
                        <td width="40%"><div align="center"><strong>&quot; </strong></div></td>
                        <td width="60%"><div align="center"><strong> 
                            <input name="Sunday16b" id="Sunday16b" type="text" value="<?PHP echo $Sunday216 ?>" size="35">
                            </strong></div></td>
                      </tr>
                    </table>
                    <p align="center">&nbsp; </p>
                    <p align="center"> 
                      <input type="submit" name="helpSubmit" value="Submit">
                    </p>
                   </form>
                </div></td>
              <td width="20%">&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table></td>
    
      </tr>
      <tr> 
        <td width="100%" height="10" valign="top"></td>
      </tr>
      <tr> 
        <td colspan="3" bgcolor="00CC00"> 
          <div align="left"> 
           <?PHP //include ("../includes/footer.html") ?>
          </div>
        </td>
      </tr>
    </table>
    </body>
    </html>
    The code above does not seem to want to post to itself. Can you please let me know where my minor error is?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,492
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Just do this for the form tag:

    <form name = "form1" method = "post">

    No action defaults to self.

    You have this condition ...
    if (isset($_POST['helpSubmit']))

    I think if someone using IE hits ENTER instead of clicking the button,
    your if statement will be "false". IE doesn't see the button when ENTER key is pressed.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •