PHP - How To Add Script :"are You Sure To Delete Data?"
Hello PHP Freaks,
I think this is just if else statement problem but im kinda lose to it.
The whole code is succesful in deleting the data from database the problem is i wanted to put a script that remind the user if he/she really sure to delete the data. By the way this is the script.
<?php // connect to the database include 'Connect.php'; // confirm that the 'student_id' variable has been set if (isset($_GET['student_id']) && is_numeric($_GET['student_id'])) { // get the 'student_id' variable from the URL $student_id = $_GET['student_id']; // delete record from database if ($stmt = $mysql->prepare("DELETE FROM student_information WHERE student_id = ? LIMIT 1")) { $stmt->bind_param("i",$student_id); $stmt->execute(); $stmt->close(); } else { echo "ERROR: could not prepare SQL statement."; } $mysql->close(); // redirect user after delete is successful header("Location: Admin_Home.php"); } else // if the 'student_id' variable isn't set, redirect the user { header("Location: Admin_Home.php"); } ?>Please help me modify these codes and where to put the missing line/s of codes. Similar TutorialsHi,
I wish to find out is there any possible that I can delete some data inside my php website but inside my sql database, the record will still at there?
Thank you.
This script add and delete data to the database, it add it correctly but it's not able to delete it. I appreciate somebody more expert to me to help me. thank you. <?php require 'include/db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); switch ($_POST['action']) { case 'Add Character': // escape incoming values to protect database $alias = mysql_real_escape_string($_POST['alias'], $db); $real_name = mysql_real_escape_string($_POST['real_name'], $db); $address = mysql_real_escape_string($_POST['address'], $db); $city = mysql_real_escape_string($_POST['city'], $db); $state = mysql_real_escape_string($_POST['state'], $db); $zipcode_id = mysql_real_escape_string($_POST['zipcode_id'], $db); $alignment = ($_POST['alignment'] == 'good') ? 'good' : 'evil'; // add character information into database tables $query = 'INSERT IGNORE INTO comic_zipcode (zipcode_id, city, state) VALUES ("' . $zipcode_id . '", "' . $city . '", "' . $state . '")'; mysql_query($query, $db) or die (mysql_error($db)); $query = 'INSERT INTO comic_lair (lair_id, zipcode_id, address) VALUES (NULL, "' . $zipcode_id . '", "' . $address . '")'; mysql_query($query, $db) or die (mysql_error($db)); // retrieve new lair_id generated by MySQL $lair_id = mysql_insert_id($db); $query = 'INSERT INTO comic_character (character_id, alias, real_name, lair_id, alignment) VALUES (NULL, "' . $alias . '", "' . $real_name . '", ' . $lair_id . ', "' . $alignment . '")'; mysql_query($query, $db) or die (mysql_error($db)); // retrieve new character_id generated by MySQL $character_id = mysql_insert_id($db); if (!empty($_POST['powers'])) { $values = array(); foreach ($_POST['powers'] as $power_id) { $values[] = sprintf('(%d, %d)', $character_id, $power_id); } $query = 'INSERT IGNORE INTO comic_character_power (character_id, power_id) VALUES ' . implode(',', $values); mysql_query($query, $db) or die (mysql_error($db)); } if (!empty($_POST['rivalries'])) { $values = array(); foreach ($_POST['rivalries'] as $rival_id) { $values[] = sprintf('(%d, %d)', $character_id, $rival_id); } // alignment will affect column order $columns = ($alignment = 'good') ? '(hero_id, villain_id)' : '(villain_id, hero_id)'; $query = 'INSERT IGNORE INTO comic_rivalry ' . $columns . ' VALUES ' . implode(',', $values); mysql_query($query, $db) or die (mysql_error($db)); } $redirect = 'list_characters.php'; break; case 'Delete Character': // make sure character_id is a number just to be safe $character_id = (int)$_POST['character_id']; // delete character information from tables $query = 'DELETE FROM c, l USING comic_character c, comic_lair l WHERE c.lair_id = l.lair_id AND c.character_id = ' . $character_id; mysql_query($query, $db) or die (mysql_error($db)); $query = 'DELETE FROM comic_character_power WHERE character_id = ' . $character_id; mysql_query($query, $db) or die (mysql_error($db)); $query = 'DELETE FROM comic_rivalry WHERE hero_id = ' . $character_id . ' OR villain_id = ' . $character_id; mysql_query($query, $db) or die (mysql_error($db)); $redirect = 'list_characters.php'; break; case 'Edit Character': // escape incoming values to protect database $character_id = (int)$_POST['character_id']; $alias = mysql_real_escape_string($_POST['alias'], $db); $real_name = mysql_real_escape_string($_POST['real_name'], $db); $address = mysql_real_escape_string($_POST['address'], $db); $city = mysql_real_escape_string($_POST['city'], $db); $state = mysql_real_escape_string($_POST['state'], $db); $zipcode_id = mysql_real_escape_string($_POST['zipcode_id'], $db); $alignment = ($_POST['alignment'] == 'good') ? 'good' : 'evil'; // update existing character information in tables $query = 'INSERT IGNORE INTO comic_zipcode (zipcode_id, city, state) VALUES ("' . $zipcode_id . '", "' . $city . '", "' . $state . '")'; mysql_query($query, $db) or die (mysql_error($db)); $query = 'UPDATE comic_lair l, comic_character c SET l.zipcode_id = ' . $zipcode_id . ', l.address = "' . $address . '", c.real_name = "' . $real_name . '", c.alias = "' . $alias . '", c.alignment = "' . $alignment . '" WHERE c.character_id = ' . $character_id . ' AND c.lair_id = l.lair_id'; mysql_query($query, $db) or die (mysql_error($db)); $query = 'DELETE FROM comic_character_power WHERE character_id = ' . $character_id; mysql_query($query, $db) or die (mysql_error($db)); if (!empty($_POST['powers'])) { $values = array(); foreach ($_POST['powers'] as $power_id) { $values[] = sprintf('(%d, %d)', $character_id, $power_id); } $query = 'INSERT IGNORE INTO comic_character_power (character_id, power_id) VALUES ' . implode(',', $values); mysql_query($query, $db) or die (mysql_error($db)); } $query = 'DELETE FROM comic_rivalry WHERE hero_id = ' . $character_id . ' OR villain_id = ' . $character_id; mysql_query($query, $db) or die (mysql_error($db)); if (!empty($_POST['rivalries'])) { $values = array(); foreach ($_POST['rivalries'] as $rival_id) { $values[] = sprintf('(%d, %d)', $character_id, $rival_id); } // alignment will affect column order $columns = ($alignment = 'good') ? '(hero_id, villain_id)' : '(villain_id, hero_id)'; $query = 'INSERT IGNORE INTO comic_rivalry ' . $columns . ' VALUES ' . implode(',', $values); mysql_query($query, $db) or die (mysql_error($db)); } $redirect = 'list_characters.php'; break; case 'Delete Selected Powers': if (!empty($_POST['powers'])) { // escape incoming values to protect database-- they should be numeric // values, but just to be safe $powers = implode(',', $_POST['powers']); $powers = mysql_real_escape_string($powers, $db); // delete powers $query = 'DELETE FROM comic_power WHERE power_id IN ("' . $powers . '")'; mysql_query($query, $db) or die (mysql_error($db)); $query = 'DELETE FROM comic_character_power WHERE power_id IN ("' . $powers . '")'; mysql_query($query, $db) or die (mysql_error($db)); } $redirect = 'edit_power.php'; break; case 'Add New Power': // trim and check power to prevent adding blank values $power = trim($_POST['new_power']); if ($power != '') { // escape incoming value $power = mysql_real_escape_string($power, $db); // create new power $query = 'INSERT IGNORE INTO comic_power (power_id, power) VALUES (NULL, "' . $power . '")'; mysql_query($query, $db) or die (mysql_error($db)); } $redirect = 'edit_power.php'; break; default: $redirect = 'list_characters.php'; } header('Location: ' . $redirect); ?> Hi all, I'am new with PHP, and I need help with this one. I have this XML structu Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <popis> <student> <prezime>Brkic</prezime> <ime>Ivica</ime> <index>D-142</index> </student> <student> <prezime>Cizek</prezime> <ime>Pero</ime> <index>D-143</index> </student> </popis> and I have this PHP code to get all elements from XML file to html table: <?php $doc = new DOMDocument(); $doc->load( 'student.xml' ); $popis = $doc->getElementsByTagName( "student" ); echo <<<EOF <table> <tr> <th width=100 >IME</th> <th width=100>PREZIME</th> <th width=100>INDEX</th> </tr> EOF; foreach( $popis as $student ) { $imena = $student->getElementsByTagName( "ime" ); $ime = $imena->item(0)->nodeValue; $prezimena= $student->getElementsByTagName( "prezime" ); $prezime= $prezimena->item(0)->nodeValue; $indexi = $student->getElementsByTagName( "index" ); $index = $indexi->item(0)->nodeValue; echo <<<EOF <tr> <td>{$ime}</td> <td>{$prezime}</td> <td>{$index}</td> </tr> EOF; } echo '</table>'; ?> Now I would like to know how to delete node from XML document? Something like, when I enter number of node I wanna delete in some iput field, or by searching, what ever, just that I can specify which node to delete... My eng is not very good, hope you understand... ty It echoes only ERROR and i don't know why?can i get some help please? 1.index.php: Code: [Select] ... <tr> <td width="128"><?php echo $row_Recordset1['pacientID']; ?></td> <td width="111"><?php echo $row_Recordset1['nume']; ?></td> <td width="128"><?php echo $row_Recordset1['prenume']; ?></td> <td width="122"><?php echo $row_Recordset1['cnp']; ?></td> <td width="192"><?php echo $row_Recordset1['data']; ?></td> <td width="192"><a href="delete_inregistrare.php?pacientID=<? echo $rows['pacientID']; ?>">Elimiare Pacient</a></td> </tr> ... 2.delete_inregistrare.php Code: [Select] <?php $host="#####"; $username="#####"; $password="######"; $db_name="model_healthcare"; $tbl_name="pacienti"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $pacientID=$_GET['pacientID']; $sql="DELETE FROM $tbl_name WHERE pacientID='$pacientID'"; $result=mysql_query($sql); if($result){ echo "Deleted Successfully"; } else { echo "ERROR"; } mysql_close(); ?> hello i have this code here to delete people form a call list but it is not deleting form it could I get a some help? the form Code: [Select] <?php include '../config.php'; $query="SELECT * FROM call_list WHERE ecs = 'Jam' order by date desc"; $result=mysql_query($query); echo mysql_error(); //////////////// Now we will display the returned records in side the rows of the table///////// while($row = mysql_fetch_array($result)) { echo " <table id='call_list'> <form name='Call_delet' action='del.php' method='get'> <tr> <td class='call_names'> $row[Fname] $row[Lname] </td> <td class='call_numbers'> $row[phone] </td> <td class='call_email'> $row[email] </td> <td class='call_email'> $row[calltime] </td> <td> <a href='del.php?del=$row[id]'>Del</a> </td> </tr> </form> </table> "; } ?> del.php page Code: [Select] <?php include '../config.php'; if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; $result = mysql_query("DELETE FROM call_list WHERE id=$id") or die(mysql_error()); header("Location: view.php"); } else { echo"dident work"; } ?> Not sure if I wrote this correctly but if anyone can just scan through this and let me know if it's fine. Thanks Code: [Select] <?php $db_link=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("commercial"); $sql = "DELETE FROM `comm` WHERE `date_created` < DATE_SUB(NOW(),INTERVAL 14 DAY)"; $result2 = mysql_query($sql, $db_link); ?> Hi, I need some help figuring out my problem. I currently have a script that retrieves records from a mysql database, then has checkboxes to enable to delete a record? Any help where I might be going wrong as it displays, but doesn't delete?? Thanks Code: [Select] <?php require_once('includes/config.php'); $sql="SELECT * FROM members ORDER BY member_id"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="413" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td colspan="5" bgcolor="#FFFFFF"><strong>Delete a Member</strong> </td> </tr> <tr> <td width="48" align="center" bgcolor="#FFFFFF">#</td> <td width="42" align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td width="129" align="left" bgcolor="#FFFFFF"><strong>First Name</strong></td> <td width="152" align="left" bgcolor="#FFFFFF"><strong>Last Name</strong></td> <td width="152" align="left" bgcolor="#FFFFFF"><strong>Email</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['member_id']; ?>"></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['member_id']; ?></td> <td align="left" bgcolor="#FFFFFF"><? echo $rows['firstname']; ?></td> <td align="left" bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="left" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ $id = $checkbox[$i]; $sql = "DELETE FROM members WHERE member_id='$id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete-member.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table>
In the same $-POST , i wanted to perform update and delete. With the updated and deleted database, I need to select the updated data from the database. However, it tells me: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in... .I am new to sql in php, is it true that i cannot perform sql in this way? Or is there any suggestion to perform select straight after deleting and updating? CANCEL BOOK RESERVATION if(isset($_POST['cancelres'])) { $query = "DELETE FROM reserved_books WHERE id='$resid';"; //delete reservation $query .="UPDATE reserved_books SET queue = queue - 1 WHERE bookid = '$bookid' AND queue > '$bookqueue';";//update queue number where reservation that queue behind/after/ the current reservation $query_run = mysqli_multi_query($connection, $query); if($query_run) { $_SESSION['success'] = "Reservation Cancelled"; } else { $_SESSION['status'] = " Reservation Not Cancelled"; } $query= "SELECT title FROM books WHERE id = '$bookid';"; //get book title from db $query_run = mysqli_query($connection,$query); if(mysqli_num_rows($query_run)>0) { foreach ($query_run as $row) { $title = $row['title']; } } $bookres = "SELECT * FROM reserved_books WHERE bookid = '$bookid' AND queue = 1"; $bookres_run = mysqli_query($connection,$bookres); foreach($bookres_run as $row) { $res_username = $row['username']; $res_id = $row['id']; } $query= "SELECT option_value FROM settings WHERE option_name = 'email_temp_rescollect'"; //get email template from db $query_run = mysqli_query($connection,$query); if(mysqli_num_rows($query_run)>0) { $row = mysqli_fetch_array($query_run); $rescollect_template = $row[0]; }}
Hello,
First of all I'd like to say thank you for all the great information on the forums, I've been reading a lot on here lately.
I've started to make a website where users can log in and submit items to a database, which is then displayed on another page.
If Tom and Bill both post 10 items, all 20 items will be displayed on the "listings" page, however on the main log in screen Tom will only see his own 10 items and Bill will see his own 10 items.
This is all working perfectly, however, I now need to add a delete button so that they can delete specific items.
I have loosely followed this tutorial here to get the table to display as I want it (amongst a few other things, such as the user logins) http://www.wickham43...mphptomysql.php
I've added the delete button in the PHP loop for each row, I just can't figure out how to delete the specific row when clicked.
Any help would be really appreciated
Edited by eklem, 22 October 2014 - 08:10 AM. This topic has teleported to Third Party PHP Scripts. Beam me up, Scotty. http://www.phpfreaks.com/forums/index.php?topic=343682.0 Hello,
I'm working on a project that requires me to have stock / fake demo files that will be replaced with real files provided by users... I need something to take space and then when people actually start using the site and inputting data, then I can replace each file with new, unique files.
I have some idea of how this would work.
I would need incremented or non-matching identifiers and then a script that probably works on an if statement
like
If new data, take first list of data, delete, replace with new data. Something like that.
Maybe some of the great coders here can help this noob out. So here is what I have so far: Code: [Select] //set age criteria for deletion $age = 60; //get current date $datenow = date("Y-m-d"); //set the range we want to delete $delete_range = $datenow - $age; //get old user_id from users table $oldusers_users = mysql_query ("SELECT user_id FROM users WHERE lastvisit < $delete_range "); //get user_id from images table that correspond to users table $oldusers_images = mysql_query ("SELECT user_id FROM images WHERE $oldusers_users=user_id.images "); //find folders that correspond to the usernames and delete $oldusers_files = mysql_query ("SELECT username FROM users WHERE lastvisit < $delete_range "); //print out username //$result = mysql_($oldusers_files); $foldername = mysql_result($oldusers_files, 0); $sigspath = "sigs/"; unlink($sigspath . $foldername . ".gif/index.php"); rmdir($sigspath . $foldername . ".gif"); //now delete user_id's from database mysql_query("DELETE * FROM users WHERE user_id=$oldusers_users"); mysql_query("DELETE * FROM images WHERE user_id=$oldusers_images"); unset($oldusers_users, $oldusers_images, $oldusers_files, $foldername, $sigspath ); mysql_close($link); Right now it is only returning the first entry, not the entire list that meets the criteria. It does delete that one file though but does not remover the rows from the database. I am sure the database stuff is jacked up I am really new to that part. What am I doing wrong here or is there a better way to do this perhaps Hi all. Here is my scripts which allow user to check multiple rows of data and delete it , but it require select data and click for twice to delete the rows , what should be the error? Code: [Select] <form name="frmSearch" method="post" action="insert-add.php"> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">ID </div></th> <th width="198"> <div align="center">First Name </div></th> <th width="198"> <div align="center">Last Name </div></th> <th width="250"> <div align="center">Mobile Company </div></th> <th width="100"> <div align="center">Cell </div></th> <th width="100"> <div align="center">Workphone </div></th> <th width="100"> <div align="center">Group </div></th> </tr> </form> <? echo "<form name='form1' method='post' action=''>"; while($objResult = mysql_fetch_array($objQuery)) { echo "<tr>"; echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>"; echo "<td>$objResult[addedrec_ID] </td>"; echo "<td>$objResult[FirstName]</td>"; echo "<td>$objResult[LastName] </td>"; echo "<td>$objResult[MobileCompany] </td>"; echo "<td>$objResult[Cell] </td>"; echo "<td>$objResult[WorkPhone] </td>"; echo "<td>$objResult[Custgroup] </td>"; echo "</tr>"; } echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">"; if (isset($_POST['delete']) && isset($_POST['checkbox'])) // from button name="delete" { $checkbox = ($_POST['checkbox']); //from name="checkbox[]" $countCheck = count($_POST['checkbox']); for($d=0;$d<$countCheck;$d++) { $del_id = $checkbox[$d]; $sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id"; $result2=mysql_query($sql) or trigger_error(mysql_error());;; } if($result2) { $fgmembersite->GetSelfScript(); } else { echo "Error: ".mysql_error(); } } echo "</form>"; Thanks for every reply. <body> <?php include 'sql.php'; $query = "SELECT * FROM validation"; $result = mysqli_query($con , $query); $rows = mysqli_fetch_assoc($result) ; $totals = mysqli_num_rows($result) ; ?> <div id="css"> <form > <table width="80%" border="0" cellpadding="2" cellspacing="2" > <caption><h2>Personal Details of Customers</h2></caption> <tr class="white"> <td bgcolor="#330033"> </td> <td bgcolor="#330033"> Id Number </td> <td bgcolor="#330033"> Full Name </td> <td bgcolor="#330033"> Email Address </td> <td bgcolor="#330033"> Website </td> <td bgcolor="#330033"> Comment </td> <td bgcolor="#330033"> Time </td> </tr> <?php while($rows=mysqli_fetch_assoc($result) { <tr> <input type="raido" name="ID" value="<?php echo $rows['ID']; ?>" /> <td bgcolor="#FFFFCC"><?php echo $rows['ID'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Name'];?> </td> <td bgcolor="#FFFFCC"><?php echo $rows['Email'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Website'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Comment'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Time'];?></td> <td> </td> <td> <a href="delete.php? ID= "$rows[ID]" /"> <input type="submit" name="del" value="Delete" /> </a> <input type="button" name= "edit" value="Edit" /> </td> </tr> }?> </table> </form> </div> </body> Ok this is puzzleing. I am geting "Could not delete data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1". but its is deleting the entry that needs to be removed. The "1" is the entry. Just not sure what is causing the error. I do have another delete php but I have put that on the back burning for the time being.
<?php $con = mysqli_connect("localhost","user","password","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20 "); $amp20ptid = $_POST['amp20ptid']; // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $amp20ptid)); { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?> I'm trying to set it so that it will delete an entire populated directory based upon a value in the database then after finishing that to go back and delete that row in the database. my current code is Code: [Select] <?php $page_title = "Central Valley LLC | Photo Addition" ?> <?php include("header.php"); ?> <?php include("nav.html"); ?> <div id="content"> <form action="delprod.php" method="post" enctype="multipart/form-data"> <label for="which">Choose A Product To Remove:</label> <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT * FROM Products"); echo "<select name=\"which\">"; while($row = mysql_fetch_array($result)) { echo "<option "; echo "value=\"" . $row['id'] . "\">"; echo $row['Name'] . "</option>"; } echo "</select>"; mysql_close($con); ?> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--#content--> <?php include("footer.html") ?> and the delete script Code: [Select] <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT id FROM Products WHERE id=$_POST['which']"); $row = mysql_fetch_array($result) chdir('assets'); chdir('images'); $mydir = $row . '/'; $d = dir($mydir); while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink($_POST['which'] . '/' . $entry); } } rmdir($mydir); $result = mysql_query("DELETE * FROM Producs WHERE id=$_POST['which']"); ?> Thank you in advance for all your help. any easier ways of approaching this will be welcome as well Hi everyone, I have created a HTML form for collecting data on a web page, ie, name, email address, etc, which works fine. I have then asked for that data to be emailed to me using the POST action in conjunction with a PHP script called "carparkprocess2.php". At the moment, the form works OK on the web page, the confirmation message to say the data has been submitted successfully works OK, but the email that should display the information entered into the form doesn't work properly. It comes through and is formatted OK, but the form information is missing. I've been trying to resolve this issue for 2 days straight now and have tried loads of different things! Can anybody help? I need a quick answer on this one if possible Code: [Select] <?php error_reporting(E_ALL ^ E_NOTICE); // Prints all errors except Notices. /* Subject and Email Variables */ $emailSubject = 'Car Park Reservation Confirmation'; $webMaster = 'ben@maver.co.uk'; /* Gathering Data Variables */ if (!isset($_POST['name'])) { $_POST['name'] = "name"; } if (!isset($_POST['carregistration'])) { $_POST['carregistration'] = "carregistration"; } if (!isset($_POST['emailaddress'])) { $_POST['emailaddress'] = "emailaddress"; } if (!isset($_POST['numberinparty'])) { $_POST['numberinparty'] = "numberinparty"; } $body = <<<EOD <br><hr><br> Name: $name <br> Vehicle Registration: $carregistration <br> Email Address: $emailaddress <br> Number in Party: $numberinparty <br> EOD; $mailheaders .= "From: $emailaddress\r\n"; $headers .= "Content-type: text/html"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>Car Park Reservation Confirmation</title> <meta http-equiv='Content-Type' content='text/html'> <style type='text/css'> <!-- body { min-height: 100%; height: auto; background: #000000; color: #ffffff; font-size: 14px; font-family: Verdana, Arial, Helvetica, sans-serif; margin: 0; } --> </style> </head> <div> <div align='left'>Your car park reservation request has been successful</div> </div> </body> </html> EOD; echo "$theResults"; ?> Here is the HTML within the form: Code: [Select] <form method='post' action='carparkprocess2.php'> Kindly help. Am a new php programmer and am learning how to HTML form data to a php script. Have tried several times but information on html form never get submitted. For some unknown reasons, the codes are failing . Here are my codes:
<html>
and
<html>
<body> Hello, I know i'm new, i hope it wont stop you guys from putting 5 minutes of your time to help me out. I need a script to get some data from mysql and put this into a table. i have a mysql database called "denora" In there is a table called "chan" In table chan are the columns: chanid (unique number), channel, currentusers, mode_ls I would like the script to make a html table that lists the top10 channels (most "currentusers" on top) And when "mode_ls" is "Y" it must not be shown (secret channel) My knowledge of php and mysql arent that great so i really hope someone takes the time to help me uit Kind regards Stefan Hello, I am writing a data retrieval script, in order to print data stored in a DB. For some reason the script does not work.. More details below.. Code: [Select] the form that calls the initiator script.. <form method='get' action="init.Get.php"> <div><input type="submit" name="get" value="See Data"></div> </form> Code: [Select] the initiator script <?php include 'dataGet.class.php'; $data= new getData(); $data= getData($name, $email, $text); ?> Code: [Select] my class.. <?php class getData { private $name; private $email; private $text; function __construct(){ $this->host = 'localhost'; $this->uname = 'root'; $this->pword = '1111'; $this->dbname = 'teststorage'; $this->dbtable = 'userData'; } function getData($name, $email, $text){ $this->dbconnect = mysql_connect($this->host, $this->uname, $this->pword); if (!$this->dbconnect) die("Connection Unable " . mysql_error()); mysql_select_db($this->dbname); $sql_query = "SELECT * FROM $this->dbtable "; $result = mysql_query($sql_query); if ($result){ echo $result; } else{ echo "Retrieval Unsuccesful"; } mysql_close($sql_query); } } ?> Can someone please tell me what am I doing wrong? Thank you in advance. |