This should be very easy for someone that is familiar with PHP and MySQL. I need a form where I enter the record "id" and then the script asks me if I'm sure I want to delete the record from the database, then proceeds to deleting it from the database. Your help would be very appreciated. This is what I have so far: <?php $dbhost = 'localhost'; $dbuser = 'username'; $dbpass = 'Pasword'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = 'DELETE FROM alexa WHERE id=39'; mysql_select_db('database'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not delete data: ' . mysql_error()); } echo "Deleted data successfully\n"; mysql_close($conn); ?> PHP:
Actually that is the part that I need made. If it could all fit in the same script that would be great. Thank you
Refer this <script type="text/javascript"> function check(){ var cnfrm = confirm("Are you sure?"); if(cnfrm){ return true; }else{ return false; } } </script> <?php $dbhost = 'localhost'; $dbuser = 'username'; $dbpass = 'password'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } mysql_select_db('database'); if(isset($_POST['submit'])){ $id = $_POST['id']; $sql = "DELETE FROM alexa WHERE id=$id"; $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not delete data: ' . mysql_error()); } echo "Deleted data successfully\n"; mysql_close($conn); } ?> <form action="" method="post"> <label>Id:</label><input type="text" name="id" /> <input type="submit" value="submit" name="submit" onclick="return check();"/> </form>