Jump to content

[SOLVED] simple html/php question


mybluehair

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.