PHP - Alert On Delete
Hello, I had a page that lists the tags in a php page, I had make a link looks like : tag.php?ID=2&action=delete I need to give an alert before the tag being deleted. how can I do this? Thanks Similar TutorialsThis should be a simple task I am just not fully grasping laravel yet. I have my controllers view and models setup. I want to use my users.destroy route to delete my row in the db. But I want to do it a certain way. I want to have an alert show In my alert area on my page asking to confirm the deletion of a certain user. Im assuming I need to pass the user id in a session to an alert to confirm my delete on a delete button click. Click 1 button to open an alert on the top of my page if I click confirm it calls user.destroy.
<div class="container"> <div class="row justify-content-center"> <div class="col-md-12"> <div class="card"> <div class="card-header"> <h4>View All Users</h4> @if(session()->get('success')) <div class="alert alert-success"> {{ session()->get('success') }} </div> @endif @if(session()->get('danger')) <div class="alert alert-danger"> {{ session()->get('danger') }} </div> @endif </div> <div class="card-body"> <div class="text-center my-2"> <a href="{{ route('register') }}" class="btn btn-primary">New User</a> </div> <div> <table class="table table-striped table-bordered"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Email</th> <th>Username</th> <th colspan="2">Actions</th> </tr> </thead> <tbody> @foreach($users as $user) <tr> <th>{{$user->id}}</th> <td>{{$user->name}}</td> <td>{{$user->email}}</td> <td>{{$user->username}}</td> <td class="text-center"> <a href="{{ route('users.show', $user->id) }}" class="btn btn-primary mr-3">Show</a> <a href="{{ route('users.edit', $user->id) }}" class="btn btn-info text-white ml-3">Edit</a> <a href="#" class="btn btn-danger">Delete</a> </td> </tr> @endforeach </tbody> </table> public function destroy($id) { User::find($id)->delete(); return redirect()->route('users.index')->with('success','User Deleted'); } Route::resource('users', 'UserController');
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> Hi,
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.
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, can anybody check on this code? I don't have any errors in it, except that the supposedly alert after I deleted an information is not working. Thank you very much. **This is a modified code provided by a friend. It worked originally (I just lost the original file since I sold my old computer xD Here's the code: <?php include("dbconnection.php"); if(mysql_num_rows($result) > 0) { $query = "SELECT * FROM records WHERE id = '".$_GET["id"]."'"; $result = mysql_query($query, $connection); $status = mysql_result($result, 0, "status"); $territory = mysql_result($result, 0, "territory"); $job_title = mysql_result($result, 0, "job_title"); $area_of_work = mysql_result($result, 0, "area_of_work"); $employer = mysql_result($result, 0, "employer"); $department = mysql_result($result, 0, "department"); $location = mysql_result($result, 0, "location"); $date_posted = mysql_result($result, 0, "date_posted"); $closing_date = mysql_result($result, 0, "closing_date"); $gender = mysql_result($result, 0, "gender"); $first_name = mysql_result($result, 0, "first_name"); $last_name = mysql_result($result, 0, "last_name"); $telephone_number = mysql_result($result, 0, "telephone_number"); $title = mysql_result($result, 0, "title"); $address_1 = mysql_result($result, 0, "address_1"); $address_2 = mysql_result($result, 0, "address_2"); $address_3 = mysql_result($result, 0, "address_3"); $city = mysql_result($result, 0, "city"); $country = mysql_result($result, 0, "country"); $postal_code = mysql_result($result, 0, "postal_code"); $website = mysql_result($result, 0, "website"); $email_address = mysql_result($result, 0, "email_address"); $cg_comment = mysql_result($result, 0, "cg_comment"); $date_emailed = mysql_result($result, 0, "date_emailed"); $mailing_comments= mysql_result($result, 0, "mailing_comments"); $telesales_comments= mysql_result($result, 0, "telesales_comments"); } if(isset($_POST["btnSubmit"])) { $id = $_POST["id"]; $query = "DELETE FROM records WHERE id = '".$id."'"; mysql_query($query) or die(mysql_error()); echo "<script> alert('You have successfully deleted a record'); window.location = 'view_client.php'; </script>"; } ?> im trying to get new user messages to show up on my site.. i have looked around on google but can only find info on popup alerts.. i just need a simple javscript code that will display the number of new messages next to the link that takes them to their inbox.. if someone could point me to a site or if they have the code handy i would appreciate it more than you know.. thank you This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317425.0 Hello all; I need to throw up a confirmation alert before allowing a database deletion. Here's the code I wrote: Code: [Select] echo "<a href='task.php?option=delete\"onclick=\"return (confirm('Do you really want to delete this?'));>Delete</a>"; The idea is that the Javascript prevents the .php from completing unless the user Confirms. It works great as .html, but I've clearly done something wrong in the .php version, as it never invokes the alert. Does anyone have any idea where I went so horribly, horribly wrong? Thanks! Kyle Hi, In my attendance system i want to add email alert using php. I want the system to check the records in my db and send email to everyone that forgot to clock-in after 7:30AM from Sunday to Thursday. What i need to use for this, ideas? This might be more than just a php question but here goes anyways. I have designed a php chat room page on my home Apache server just for a few friends & family. The problem I have is the only way for me to know if anyone is on the chat room page is if I'm actually viewing the php page. Is there a way that I can have the page alert me when someone accesses it? I was thinking something like activating a popup in my browser or even a beep so as long as I'm at my computer with my browser open that I will know someone has accessed the page. So say I have a page with 3 buttons on:
<button id="1" onclick="clickFunction()">1 </button> <button id="2" onclick="clickFunction()">2</button> <button id="3" onclick="clickFunction()">3</button>How do I then create an alert displaying which was pressed? e.g: <script> function clickFunction() { alert("Button X Was Pressed"); } </script>I know in this case I could create 3 different functions but I want to use it for a page with a lot more than 3. Thanks, This is my code Code: [Select] $file = $file . $line; fclose($fh); echo "<script language= 'JavaScript'>alert(' . $file . ');</script>"; the alert box is not coming up. Please suggest a way to print the contents of the file in a alert box. Hey all - Below is my code. I'm uncertain how to move correctly code (syntax) what I'm looking to do.. When the user clicks "Next" or "Previous," the following youtube clip will load into the div tag. (With the corresponding description tag). Where do I incorporate the str_replace? And how do I make sure both the youtube clip with the correct description is loaded? Any advice is appreciated! <?php $youtubeIds = array("rHNtuaVHenM","zIAdbIMNq9g","QQ4TlJLa-n4","JccPOA12ELI","JccPOA12ELI", "TWhhXVqVB7E"); $embedCode = '<object width="853" height="505"><param name="movie" value="http://www.youtube.com/v/__YOUTUBE_ID__?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/__YOUTUBE_ID__?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="853" height="505"></embed></object>'; if(isset($_GET['youtubeclip'])) { if(is_numeric($_GET['youtubeclip'])) { if($_GET['youtubeclip'] >= 0 && $_GET['youtubeclip'] <= 5) { $youtubeclip = $_GET['youtubeclip']; } else { $youtubeclip = 0; } } else { $youtubeclip = 0; } $prevyoutubeclip = $youtubeclip-1; if($prevyoutubeclip < 0) { $prevyoutubeclip = 5; } $nextyoutubeclip = $youtubeclip+1; if($nextyoutubeclip > 5) { $nextyoutubeclib = 0; } $clip_names= array('Episode #1', 'Episode #2', 'Episode #3', 'Episode #4', 'Episode #5', 'Episode #6'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Billy Green</title> <link rel="stylesheet" type="text/css" media="screen" href="episode_style.css"> </head> <body> <div class="wrapper"> <?php include 'header.php'?> <div id="episode_content"> <div class="youtube_box"> <?php echo $embedCode; ?> </div> <h2 class="clip-description">"<?php echo $clip_names[$youtubeclip]; ?>" </h2> <div class="youtube_control"> <a href="episodes.php?youtubeclip=<?php echo $prevyoutubeclip; ?>"> Previous Clip </a> <a href="episodes.php?youtubeclip=<?php echo $nextyoutubeclip; ?>"> Next Clip </a> </div> </div> <div class="clearIt"> </div> <?php include 'footer.php'?> </div> </body> </html> When I click on this span I want it to alert the ID if the span...
<span id='" . $thisid . "' onClick='likeThis()'><img src='https://cdn1.iconfinder.com/data/icons/nuvola2/32x32/apps/amor.png'>Like</center></span> <script> function likeThis(){ var lb = $(this).attr('id'); alert(lb) } </script>However, it currently just says 'undefined'. What's wrong? Thanks, Using Javascript, how do I do an alert and show the value of a variable? thanks Hi I have a live chat integrated into my website that uses Ajax, PHP and MySQL. When two people have the chat window open they can chat and it works fine. How can I send an alert to the person being requested to chat with, or for the chat.php page to popup automatically. It prob needs to be some function constantly running in the background check the DB for new message entries. Thanks Jay Am trying to get an email address from the DB and send an alert but it's not working..
$search3 = mysql_query("SELECT email FROM users WHERE department = '$department' AND (position = '$position')") or die(mysql_error()); $acct1 = mysql_fetch_array($search3); $email = $acct1['email']; $to = $email; $subject = 'New Requisition Alert'; $message = 'You have a new message'; $headers = 'From: server@test.com' . "\r\n" . 'Reply-To: admin@test.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); Hello, I'm newbie in php. I would like to ask how to start writing php command in order to send due date alert via email. i'm successfully connect php with google smtp. the situation is like this. i would like to send notification to the user if the user is not return back the vessel to the laboratory before 5pm on the same day. Just a quick one for anyone here that knows. I am setting up a small catalog site that runs off a MySQL database. On each product page there is a main image and six supporting thumbnails of different views of said product. I have six thumbnails (front, back, left, right, modelimage1, modelimage2) with then six main images to match. I want to be able to click on each of the thumbnails and have it swap the main image to match. I have given the main image an ID so maybe I could use a bit of javascript to swap the mainimage1 (<? echo "$mainimage1"; ?>) ....... to........ mainimage2 (<? echo "$mainimage2"; ?>) when i click on Any ideas of where to start? Its really just a simple thumbnail gallery i guess! I'm a newbie so as simple as possible would be great! Code: [Select] $id = $_GET['id']; // will be equal to '1' if the url ends in ?id=1 it would be '2' if it ended in ?id=2 etc. $query="SELECT * FROM ruxxshop WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $name=mysql_result($result,$i,"name"); $subtitle=mysql_result($result,$i,"subtitle"); $description=mysql_result($result,$i,"description"); $colour=mysql_result($result,$i,"colour"); $standardprice=mysql_result($result,$i,"standardprice"); $standardshoplink=mysql_result($result,$i,"standardshoplink"); $largeprice=mysql_result($result,$i,"largeprice"); $largeshoplink=mysql_result($result,$i,"largeshoplink"); //main images $mainimage1=mysql_result($result,$i,"mainimage1"); //front image $mainimage2=mysql_result($result,$i,"mainimage2"); //back image $mainimage3=mysql_result($result,$i,"mainimage3"); //left image $mainimage4=mysql_result($result,$i,"mainimage4"); //right image $mainimage5=mysql_result($result,$i,"mainimage5"); //model image 1 $mainimage6=mysql_result($result,$i,"mainimage6"); //model image 2 //thumbnail images $leftimage=mysql_result($result,$i,"leftimage"); $rightimage=mysql_result($result,$i,"rightimage"); $backimage=mysql_result($result,$i,"backimage"); $frontimage=mysql_result($result,$i,"frontimage"); $modelimage1=mysql_result($result,$i,"modelimage1"); $modelimage2=mysql_result($result,$i,"modelimage2"); ?> <style type="text/css"> <!-- .areasmenu { font-size: 13px; color: #CCC; } .basemenu { text-align: left; font-size: 9px; font-family: Verdana, Geneva, sans-serif; } .rightalignmenu { font-family: Verdana, Geneva, sans-serif; font-size: 10px; font-style: normal; color: #999; text-align: right; vertical-align: top; } .thumbtable { background-color: #E2E2E2; } .maintable { background-image: url(Images/Main%20Content/background.jpg); } .BagTitle { color: #666; font-size: 14px; font-family: Verdana, Geneva, sans-serif; font-weight: bold; vertical-align: top; } .leftaligntext { font-family: Verdana, Geneva, sans-serif; font-size: 11px; color: #666; vertical-align: top; } .rightaligntext { font-family: Verdana, Geneva, sans-serif; font-size: 11px; color: #666; text-align: right; vertical-align: top; } .thumbpics { font-size: 7px; } a:link { color: #999; text-decoration: none; } a:visited { text-decoration: none; color: #999; } a:hover { text-decoration: none; color: #999; } a:active { text-decoration: none; color: #999; } --> </style> <p> <? ++$i; }; ?> </p> <p> </p> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th rowspan="2" align="left" valign="top" scope="col"><a href="grid.html"><img src="Images/Main Content/Ruxx Logo Black.jpg" alt="Home Page" width="100" height="28" border="0" /></a> </th> <th width="316" height="20" valign="top" class="rightalignmenu" scope="col"><span class="areasmenu"><a href="/grid1.html">WOMENS</a></span></th> <th width="74" height="20" valign="top" class="rightalignmenu" scope="col"><span class="areasmenu">MENS</span></th> <th width="131" height="20" valign="top" class="rightalignmenu" scope="col"><span class="areasmenu">ACCESSORIES</span></th> </tr> <tr> <td height="20" colspan="3" class="rightalignmenu"><a href="index.html">Home</a> - <a href="/about.html">About Ruxx</a>- The Ruxx Store - Bag Sizing & Details - <a href="/contact.html">Contact</a> - Register For Info</td> </tr> </table> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="maintable" valign="middle" > <tr class="greybackground"> <td width="230" height="440" valign="top"><table width="230" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="30" height="60" nowrap="nowrap"> </td> <td height="60"> </td> <td width="20" height="60" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="15" nowrap="nowrap"> </td> <td height="15" class="BagTitle"><font face="Arial, Helvetica, sans-serif"><? echo "$name"; ?></font></td> <td width="20" height="15" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="15" nowrap="nowrap"> </td> <td height="15" class="leftaligntext"><font face="Arial, Helvetica, sans-serif"><? echo "$subtitle"; ?></font></td> <td width="20" height="15" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="50" nowrap="nowrap"> </td> <td height="50"> </td> <td width="20" height="50" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="100" nowrap="nowrap"> </td> <td height="100" class="leftaligntext"><font face="Arial, Helvetica, sans-serif"><? echo "$description"; ?></font></td> <td width="20" height="100" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="55" nowrap="nowrap"> </td> <td height="55"> </td> <td width="20" height="55" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="100" nowrap="nowrap"> </td> <td height="100" class="leftaligntext"><font face="Arial, Helvetica, sans-serif"><? echo "$colour"; ?></font></td> <td width="20" height="100" nowrap="nowrap"> </td> </tr> </table></td> <td valign="top"><img src="<? echo "$mainimage1"; ?>" width="340" height="440" name="MainImage" /></td> <td width="230" valign="top"><table width="230" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" height="60"> </td> <td height="60"> </td> <td width="30" height="60"> </td> </tr> <tr> <td width="20" height="15"> </td> <td height="15" class="rightaligntext"><font face="Arial, Helvetica, sans-serif">STANDARD SIZE</font><font face="Arial, Helvetica, sans-serif">: <? echo "$standardprice"; ?></font></td> <td width="30" height="15"> </td> </tr> <tr> <td width="20" height="15"> </td> <td height="15" class="rightaligntext"><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$standardshoplink"; ?>">Buy This Bag</a></font></td> <td width="30" height="15"> </td> </tr> <tr> <td width="20" height="40"> </td> <td height="40"> </td> <td width="30" height="40"> </td> </tr> <tr> <td width="20" height="15"> </td> <td height="15" class="rightaligntext"><font face="Arial, Helvetica, sans-serif">LARGE SIZE</font><font face="Arial, Helvetica, sans-serif">: <? echo "$largeprice"; ?></font></td> <td width="30" height="15"> </td> </tr> <tr> <td width="20" height="15"> </td> <td height="15" class="rightaligntext"><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$largeshoplink"; ?>">Order This Bag</a></font></td> <td width="30" height="15"> </td> </tr> <tr> <td width="20" height="20"> </td> <td height="20"> </td> <td width="30" height="20"> </td> </tr> <tr> <td width="20" height="200"> </td> <td height="200"><table width="150" border="0" align="right" cellpadding="0" cellspacing="5" class="thumbtable"> <tr> <td height="60"><img src="<? echo "$frontimage"; ?>" width="65" height="65" /></td> <td height="60"><img src="<? echo "$backimage"; ?>" width="65" height="65" /></td> </tr> <tr> <td height="60"><img src="<? echo "$leftimage"; ?>" width="65" height="65" /></td> <td height="60"><img src="<? echo "$rightimage"; ?>" width="65" height="65" /></td> </tr> <tr> <td height="60"><img src="<? echo "$modelimage1"; ?>" width="65" height="65" /></td> <td height="60"><img src="<? echo "$modelimage2"; ?>" width="65" height="65" /></td> </tr> </table></td> <td width="30" height="0"> </td> </tr> </table></td> </tr> </table> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="15" valign="bottom" class="areasmenu"><span class="basemenu">Terms & Conditions - Refund Policy - Privacy Policy - Delivery Info - Copyright Ruxx 2010 ©</span></td> </tr> </table> Thanks |