i want to use insert and delete query at the same time but its not working only insert query run here is my code,every thing is working but delete query.....

include("conn.php");
$a=$_GET['email'];

if(isset($_POST['submit']));
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$password=$_POST['password'];
$city=$_POST['city'];
$address=$_POST['address'];
$gender=$_POST['gender'];
$degree=$_POST['degree'];
$specialization=$_POST['specialization'];
$experiance=$_POST['experiance'];
$salary=$_POST['salary'];
$designation=$_POST['designation'];

$insert=mysql_query ("insert into admin (firstname, lastname, email, password, city, address, gender, degree, specialization, experiance, salary, designation) values ('$firstname', '$lastname', '$email', '$password', '$city', '$address', '$gender', '$degree', '$specialization', '$experiance', '$salary', '$designation')");

$del=mysql_query("delete from signup where email='$a' ");

header("location: requests.php");

at the last header is also working but delete query is not working plz help me out in this matter

Dani AI

Generated

Three quick, concrete things to check first — these are the usual causes and match what others have hinted at here. is right that the stray semicolon after the if(isset($_POST['submit'])) line effectively cancels the conditional; remove that. Also confirm which email you're using for the DELETE: your script reads $a from GET but the form posts an email field — make those consistent. Finally, add error reporting for the query (what suggested) so the delete doesn't fail silently.

Practical debugging steps

  • Remove the trailing semicolon on the if(...) line so the block executes only when the form is submitted.
  • Verify $_GET['email'] actually contains the expected value (use var_dump or error_log during debugging).
  • Check the query result and error message (or log the database error) instead of redirecting immediately; remember that echoing before header() will break the redirect.

A safe example using mysqli with a transaction (adapt fields to your schema):

<?php
$mysqli = new mysqli('host','user','pass','db');
if ($mysqli->connect_errno) die('Connect error');

if (!empty($_POST) && isset($_POST['submit']) && !empty($_GET['email'])) {
    $toDelete = $_GET['email'];
    $emailToInsert = $_POST['email'];

    $mysqli->begin_transaction();
    try {
        $ins = $mysqli->prepare("INSERT INTO admin (firstname, lastname, email) VALUES (?, ?, ?)");
        $ins->bind_param('sss', $_POST['firstname'], $_POST['lastname'], $emailToInsert);
        $ins->execute();

        $del = $mysqli->prepare("DELETE FROM signup WHERE email = ?");
        $del->bind_param('s', $toDelete);
        $del->execute();

        $mysqli->commit();
        header('Location: requests.php'); exit;
    } catch (Exception $e) {
        $mysqli->rollback();
        error_log($e->getMessage());
        die('DB error');
    }
}
?>

Extra tips: check affected_rows to confirm the DELETE matched a row, ensure there are no foreign-key constraints or permission issues preventing deletes, and never use raw input in SQL — prefer prepared statements and hash passwords.

Recommended Answers

All 2 Replies

Member Avatar for Member #120589

do this:

echo "delete from signup where email='$a' ";
$del=mysql_query("delete from signup where email='$a' ");

See what you get. BTW this will stop the header working.
Copy the output from the screen (SQL) and paste it into phpmyadmin SQL window and see if it works.
Also you can use the :

mysql_query("delete from signup where email='$a' ") or die(mysql_error());

Are you sure you get one email via GET and another via POST?

Also, line 4 does nothing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.