mybluehair Posted November 20, 2007 Share Posted November 20, 2007 so i have a html file, and then a php file. the html file simply has a submit button on it, and is told to go to the php file when clicked. the php file has a 'if' statement that dosnt work. im trying to get it to say "if the user pressed the submit button, then do this" i dont know how. here are my codes. html: <html> <body> <form action="dump.php" method="post"> <center> <input type="submit" value="confirm Dump"> </center> </form> </body> </html> php: <? include 'config.php'; $l; $passdump=$_SUBMIT['confirm Dump']; $query2="TRUNCATE TABLE `contacts`"; $result2=mysql_query($query2); $drop=mysql_result($result2, "password"); if ( $passdump == true ) { echo " $drop <meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=allinone.php\">"; } else { echo "Sorry, you did not confirm"; } mysql_close($l); ?> Link to comment https://forums.phpfreaks.com/topic/78129-solved-simple-htmlphp-question/ Share on other sites More sharing options...
tiki Posted November 20, 2007 Share Posted November 20, 2007 if (isset($_POST["submit"])) { // if submitted do stuff here } else { // didnt submit } Link to comment https://forums.phpfreaks.com/topic/78129-solved-simple-htmlphp-question/#findComment-395371 Share on other sites More sharing options...
mybluehair Posted November 20, 2007 Author Share Posted November 20, 2007 if (isset($_POST["submit"])) { // if submitted do stuff here } else { // didnt submit } that dosnt work. here is the new php code: <? session_start(); include 'config.php'; if($_SESSION['s_logged_n'] == 'true'){ include 'header.php'; $username = $_SESSION['s_username']; $sql = mysql_query("SELECT rank FROM Users WHERE Username='".$_SESSION['s_username']."'"); $row = mysql_fetch_array($sql); if ($row['rank'] == 2) { if (isset($_POST["submit"])) { $query2="TRUNCATE TABLE `contacts`"; $result2=mysql_query($query2); echo "<br><br><center> <td bgcolor=\"#2e3e55\"> <table style=\"width: 445px; height: 113px;\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\"> <tbody> <tr class=\"category\"> <td align=\"center\" valign=\"top\" width=\"20%\"><strong></strong><font color=\"#ffffff\"><pre>All messages were cleared. </pre></font></td> </tr>"; echo " $result2 <meta HTTP-EQUIV=\"REFRESH\" content=\"3; url=ap.php\">"; } else { echo "Sorry, you did not confirm."; } } else { echo "<center>Sorry, you do not have permissions to view this page.</center>"; } } else { include 'login.php'; } mysql_close($l); ?> i get "sorry, u did not confirm" Link to comment https://forums.phpfreaks.com/topic/78129-solved-simple-htmlphp-question/#findComment-395398 Share on other sites More sharing options...
revraz Posted November 20, 2007 Share Posted November 20, 2007 Try adding a name="submit" to your form code: <input type="submit" name="submit" value="confirm Dump"> Link to comment https://forums.phpfreaks.com/topic/78129-solved-simple-htmlphp-question/#findComment-395404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.