thecase Posted October 25, 2008 Share Posted October 25, 2008 Hi, This is my code <?php //// // Load up setting files //// require_once('./forum/SSI.php'); require_once('./mysql_connect.php'); require_once('./style.css'); //// // Get the ladder //// $query_value = empty($_POST['common']) ? empty($_GET['common']) ? 0 : $_GET['common'] : $_POST['common']; //// // Make sure the ladder has a value /// if(empty($query_value)){exit;} //// // Get current Username //// $username = $context['user']['name']; //// // Fetch users team //// $userteamcheck = "SELECT team FROM smf_members WHERE memberName='$username'" or trigger_error("Query: $userteamcheck\n<br />MySQL Error: ". mysql_error()); $userteamcheck2 = mysql_query ($userteamcheck) or die(mysql_error()); while ($userteamcheck3 = mysql_fetch_assoc($userteamcheck2)) { $teamnamme = $userteamcheck3['team']; } //// // Define points and avaliable variable //// $currentpointsp = "{$query_value}p"; $a = "a{$query_value}"; //// // Fetch points of current team //// $fetchpoints = "SELECT * FROM aacl_team WHERE teamname='$teamnamme'"; $fetchpoints2 = mysql_query ($fetchpoints) or trigger_error("Query: $fetchpoints2\n<br />MySQL Error: ". mysql_error()); while ($fetchpoints3 = mysql_fetch_assoc($fetchpoints2)) { $currentpoints = $fetchpoints3["$currentpointsp"]; } //// // Fetch the team that has more points //// $fetchmorepoints = "SELECT teamname, id FROM aacl_team WHERE $a='0' AND $currentpointsp <= $currentpoints AND teamname != '$teamnamme' LIMIT 1"; $fetchmorepoints2 = mysql_query ($fetchmorepoints) or trigger_error("Query: $fetchmorepoints2\n<br />MySQL Error: ". mysql_error()); while ($fetchmorepoints3 = mysql_fetch_assoc($fetchmorepoints2)) { $morepointteam = $fetchmorepoints3['teamname']; $morepointteamid = $fetchmorepoints3['id']; } //// // Fetch the team that has less points //// $fetchlesspoints = "SELECT * FROM aacl_team WHERE $a='0' AND $currentpointsp >= $currentpoints AND teamname != '$teamnamme'"; $fetchlesspoints2 = mysql_query ($fetchlesspoints) or trigger_error("Query: $fetchlesspoints2\n<br />MySQL Error: ". mysql_error()); while ($fetchlesspoints3 = mysql_fetch_assoc($fetchlesspoints2)) { $lesspointteam = $fetchlesspoints3['teamname']; $lesspointteamid = $fetchlesspoints3['id']; } //// // If the form is submitted //// if(isset($_POST['challengeteamsubmit2'])){ //// // Define the team id //// $teamid = $_POST['cteam']; //// // Fetch the team names //// $fetchteamname = "SELECT teamname FROM aacl_team WHERE id='$teamid'"; $fetchteamname2 = mysql_query ($fetchteamname) or trigger_error("Query: $fetchteamname2\n<br />MySQL Error: ". mysql_error()); while ($fetchteamname3 = mysql_fetch_assoc($fetchteamname2)) { $teamname2 = $fetchteamname3['teamname']; } //// // Define query value //// $query_value = $_POST['common']; //// // Define an random id //// $dbid = rand(1,5000); //// // Check if the ID is allready in the database //// $queryid = "SELECT id FROM aacl_match WHERE id='$dbid'"; $resultid = mysql_query($queryid); if (mysql_num_rows($resultid) == 2){ echo 'Error. Please go back and try again'; exit(); }else{ //// // Define the text boxs //// $server = $_POST['ip']; $max = $_POST['max']; $password = $_POST['password']; $time = $_POST['time']; $date = $_POST['date']; //// // Check for numbers only //// if (ctype_alpha($server) == TRUE) { echo '<p>Please enter a valid server IP</p>'; exit(); //// // Check if blank //// }elseif ($server == '') { echo '<p>You left server IP blank</p>'; exit(); //// // Check for numbers only //// }elseif (ctype_alpha($max) == TRUE) { echo '<p>Please enter the number of maxium people that is alloud to turn up</p>'; exit(); //// // Check if max field is left blank //// }elseif ($max == '') { echo '</p>You left max number blank. If you dont mind how many turn up please enter 0</p>'; exit(); //// // Insert match in db //// $query1 = "INSERT INTO aacl_match (`id`, `team`, `ladder`, `time`, `date`, `teamchallenged`, `ip`, `password`, `max`) VALUES ('$dbid', '$teamnamme', '$query_value', '$time', '$date', '$teamname2', '$server', '$password', '$max')"; $result1 = mysql_query ($query1) or trigger_error("Query: $query1\n<br />MySQL Error: " . mysql_error()); //// // Insert match in db for other team //// $query11 = "INSERT INTO aacl_match (`id`, `team`, `ladder`, `time`, `date`, `teamchallenged`, `ip`, `password`, `max`) VALUES ('$dbid', '$teamname2', '$query_value', '$time', '$date', '$teamnamme', '$server', '$password', '$max')"; $result11 = mysql_query ($query11) or trigger_error("Query: $query11\n<br />MySQL Error: " . mysql_error()); //// // Run a check for team //// $userteamcheck = "SELECT team FROM smf_members WHERE memberName='$username'"; $userteamcheck2 = mysql_query ($userteamcheck); while ($userteamcheck3 = mysql_fetch_assoc($userteamcheck2)) { $teamname = $userteamcheck3['team']; } //// // Teams are now unavaliable //// mysql_query("UPDATE `aacl_team` SET $a='1' WHERE teamname='$teamname'") or die(mysql_error()); mysql_query("UPDATE `aacl_team` SET $a='1' WHERE id='$teamid'") or die(mysql_error()); //// // Define the ladder to table fields //// switch ($query_value){ case 'fsr': $comms = 'fsrcommsid'; break; case 'fsta': $comms = 'fstacommsid'; break; case 'tr': $comms = 'trcommsid'; break; case 'tta': $comms = 'ttacommsid'; break; } //// //Update the db with the match ID //// mysql_query("UPDATE `aacl_team` SET $comms='$dbid' WHERE teamname='$teamname'") or die(mysql_error()); mysql_query("UPDATE `aacl_team` SET $comms='$dbid' WHERE id='$teamid'") or die(mysql_error()); echo "<p>Completed</p>"; exit(); } } } $datezone = date('T'); echo " <form action=\"test_query.php\" method=\"post\"> <input type=\"hidden\" name=\"common\" value=\"{$query_value}\" /> <font color='#F9F9F9'>Team: </font><select name='cteam'> <option value='" . $morepointteamid . "'>" . $morepointteam . "</option> <option value='" . $lesspointteamid . "'>" . $lesspointteam . "</option> </select><BR> <font color='#F9F9F9'>Time $datezone:</font> <select name='time'>"; $i = 0; while ($i <= 23) { echo "<OPTION>".date('H:i', mktime($i, 00, 0, 01, 01, 2008))."</OPTION>"; echo "<OPTION>".date('H:i', mktime($i, 30, 0, 01, 01, 2008))."</OPTION>"; $i++; } echo " </select><BR> <font color='#F9F9F9'>Date:</font> </font><select name='date'>"; $ii = 7; while ($ii <= 18) { echo "<OPTION>".date('l, F jS Y', strtotime('+' . $ii . ' days'))."</OPTION>"; $ii++; } echo " </select><BR> <font color='#F9F9F9'>Server IP:</font> <input type='text' size='25' name='ip'> <BR> <font color='#F9F9F9'>Max People:</font> <input type='text' size='2' name='max' maxlength='2'> <BR> <font color='#F9F9F9'>Server Password:</font> <input type='password' size='30' name='password'> <div align='center'> <input type='submit' name='challengeteamsubmit' value='Challenge' /></div> <input type=\"hidden\" name=\"challengeteamsubmit2\" value=\"TRUE\" /></form>"; ?> When I submit the form it just refreshes and doesnt submit anything, I try again and it refreshes again any ideas? Thanks Link to comment https://forums.phpfreaks.com/topic/130048-form-reloading/ Share on other sites More sharing options...
BoltZ Posted October 25, 2008 Share Posted October 25, 2008 Can you post a link Link to comment https://forums.phpfreaks.com/topic/130048-form-reloading/#findComment-674327 Share on other sites More sharing options...
thecase Posted October 25, 2008 Author Share Posted October 25, 2008 Well it requires registration to make it easy I attached a video so you can see what I mean http://www.mediafire.com/download.php?tjzyydmozic Thanks Link to comment https://forums.phpfreaks.com/topic/130048-form-reloading/#findComment-674383 Share on other sites More sharing options...
PFMaBiSmAd Posted October 25, 2008 Share Posted October 25, 2008 method=\"post\" will cause $_POST variables to be set. You are using $_GET variables. Link to comment https://forums.phpfreaks.com/topic/130048-form-reloading/#findComment-674390 Share on other sites More sharing options...
thecase Posted October 25, 2008 Author Share Posted October 25, 2008 Im not to sure this is what I should do but I changed it to this: <form action=\"test_query.php\" method=\"get\"> Still not working though Link to comment https://forums.phpfreaks.com/topic/130048-form-reloading/#findComment-674486 Share on other sites More sharing options...
ram4nd Posted October 25, 2008 Share Posted October 25, 2008 You can address it to itself. That way it should refresh itself. Link to comment https://forums.phpfreaks.com/topic/130048-form-reloading/#findComment-674489 Share on other sites More sharing options...
thecase Posted October 25, 2008 Author Share Posted October 25, 2008 I dont want it to refresh. It is refreshing now but not sending any data to the database. It should send data and echo Completed Link to comment https://forums.phpfreaks.com/topic/130048-form-reloading/#findComment-674492 Share on other sites More sharing options...
PFMaBiSmAd Posted October 25, 2008 Share Posted October 25, 2008 Actually, you have a mix of POST and GET - ...empty($_POST['common']) ? empty($_GET['common'])... Decide on one method and use that throughout your code. Link to comment https://forums.phpfreaks.com/topic/130048-form-reloading/#findComment-674511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.