PHP - Confirm Message Box - Php/javascript
hey guys, im pretty awful in programming, so bare with me.
im using javascript to pop-up a message box.
if user confirms, the page will insert data in mysql and redirects to the index page.
if user cancels the pop-up message, it will just stay on the main page.
but i can't seemed to pass the variables as it calls a set function...
what did i do wrong? any help from anyone is highly appreciated.
html page
<form method="post" action="seatplan_occupied.php"> <input name = "btn_seatOccupied" type = "submit" class="btnFORM" value="CONFIRM" onClick="seatOccupied()"> </form>php/javascript page (seatplan_occupied.php) <script> function seatOccupied() { document.getElementById("btn_seatOccupied").innerHTML; if (confirm("Are you sure you want to confirm your purchase?") == true) { alert("Yeay! You bought ticket/s"); <?php include("databaseconnect.php"); mysql_query("UPDATE tblseatchart SET seatSTATUS='Occupied' WHERE seatSTATUS='Selected'"); include("index.php"); ?> } else { alert("Owh No! You Cancelled to confirm... Whats wrong?"); } } </script> Similar TutorialsCan anyone help me with this delete confirm box. I have tried but somehow its not working. Can anyone help me with this? Thankz. html codes : echo "<td><a href=delete.php?id=" . $rows['id'] ." onclick=\"return confirm(Are you sure?);\">Delete</a></td>"; delete.php : <?php include "config.php"; ?> <?php $id=$_GET['id']; ?> <script type="text/javascript"> <!-- function confirmation() { var answer = confirm('Are you sure you want to delete?') if (answer){ $sql="DELETE FROM document WHERE id='$id'"; } else{ alert("Cancelled the delete!") } } </script> Hello Frnds, I have code which i am using for update a file ..... Code: [Select] $poid = $_POST['txtpoid']; $suppid = $_POST['suppid']; $custid = $_POST['custid']; $podate = $_POST['timestamp']; $poqty = $_POST['txtpoqty']; $chkqty = $_POST['chkqty']; if($chkqty<>$poqty) { ////HERE I WANT TO SHOW CONFIRM JAVASCRIPT WITH YES/NO OPTION (YOU ARE GOING TO CHANGE QUANTITY. ARE YOU SURE), IF YES THE QUERY UPDATE IF NOTHEN EXIT FROM HERE SO WHATS THE CODE please HELP///////////// } $query = ("update po SET suppid='$suppid',custid='$custid,podate='$podate',poqty='$poqty' where poid='$poid'"); if(!mysql_query($query, $link)) die ("Mysql error ....<p>".mysql_error()); Hi!! I want to delete record which i clicked the delete button in the table. I want a confirm box for delete Here is code display.php Code: [Select] <?php $cn=mysql_connect("localhost","root",""); mysql_select_db("register",$cn); $qry2=mysql_query("SELECT * FROM reg_table"); ?> <html> <head> <script type="text/javascript"> function show_confirm() { var r=confirm("Do you want to Delete?"); if (r==true) { } else { alert("You pressed Cancel!"); } } </script> </head> <body> <form action="delete.php" method="get"> <table width="200" border="1"> <tr> <th scope="col">Name</th> <th scope="col">Address</th> <th scope="col">Gender</th> <th scope="col">Qualify</th> </tr> <?php while($res=mysql_fetch_array($qry2)) { ?> <tr> <td><?php echo $res['name']; ?></td> <td><?php echo $res['adrs']; ?></td> <td><?php echo $res['gender']; ?></td> <td><?php echo $res['qualify']; ?></td> <td> <a href="edit.php?uid=<?php echo $res['id']; ?>">edit</a></td> <td> <input type="hidden" name="nid" value="<?php echo $res['id']; ?>" /> </td> <td> <input type="submit" value="Delete" name="del" onClick="return show_confirm();"> </td> </tr> <?php } ?> </table> </form> </body> </html> delete.php Code: [Select] <html> <body> <?php $cn=mysql_connect("localhost","root",""); mysql_select_db("register",$cn); $del_id=$_GET['nid']; $qry=mysql_query("delete from reg_table where id='".$del_id."' "); if($qry) { echo "deleted"; } else { echo "not deleted"; } ?> </body> </html> Hello. How can I insert a prompt to confirm the deletion of a record? Currently I have a page that lists all of the table entries with a url to pass along the variable to identify the record to delete on a hidden, secondary page. Page 1 Code: [Select] echo "<a href=\"/administrator/db/event_delete2.php?id=$row[id]\">Delete</a>"; Page 2 Code: [Select] mysql_query("DELETE FROM event_schedule WHERE id='$id' LIMIT 1"); The code may be sloppy, but it works. Now I am trying to add the speedbump of the "are you sure you want to delete this record?" Thank you. Hi, i have delete link for records and it goes to other page to delete all related records in tables. is there away to get confirmation before the delete process starts? <?Php include('session.php'); include('dbcon.php'); if(isset($_GET['Del'])) { $userid = $_GET['Del']; $query = "delete from staff where OracleID='".$userid."'"; $result = mysqli_query($con,$query); if($result) { echo "staff deleted"; } else { echo 'check the errors!'; } $query2 = "delete from attendance_records where OracleID='".$userid."'"; $result2 = mysqli_query($con,$query2); if($result2) { echo "records deleted"; } else { echo 'check the errors!'; } header("location:viewstaff.php"); } else { header("location:viewstaff.php"); } ?> how to add confirm message with php before deletion is processed? i have some code which sends a confrim link via the posted email. In hotmail it works fine, once the link is clicked they are confirmed but gmail adds %09 to the link making it break. example WHERE hash = their email hashed posted email = test@test.com confirm link(hotmail) confirm.php?email=HASH&o=test@test.com(works) confirm link(gmail)confirm.php?email=%09HASH&o=test@test.com(Doesnt work) anyone know why gmail does this? Hello, I'm working on a register script, and basically I would like the user to repeat their password. And I would like PHP to compare the to passwords, and if they both match then it continues, whereas if they don't match it calls an error. Here is what I have so far: Form: Consists of 2 text fields - subpass, and subconfirmpass PHP: $field = "subpass"; if(!$subpass == $subconfirmpass){ $form->setError($field, "* Passwords do not match"); } $field is referring to the text fields in where the user inputs their password $form is keeping track of errors in user submitted forms and the form field values that were entered correctly. I would appreciate your help, Thanks This 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.. I have while loop inside while loop and I need to add confirm button on the last loop data. here is my code: <?php error_reporting(0); date_default_timezone_set("Asia/Singapore"); //set the time zone $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); $Date_Shelve =date('Y-m-d H:i:s'); ?> <html> <head> <title>Job Order</title> <link rel="stylesheet" type="text/css" href="kanban.css" /> <style type="text/css"> #SR_date{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; margin-right: 770px; width: auto; height: auto; float: left; top : 10px; } #disp_btn{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; top: 10px; } #disp{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; top: 10px; } table { margin: 12px; margin-left: 3px; font-family: Arial, Helvetica, sans-serif; font-size: .7em; border: 1px solid #DDD; } th { font-family: Arial, Helvetica, sans-serif; font-size: .9em; background: #694; color: #FFF; padding: 2px 6px; border-collapse: separate; border: 1px solid #000; } td { font-family: Arial, Helvetica, sans-serif; font-size: .7em; border: 1px solid #DDD; text-align: left; } table.mytable { margin: 12px; margin-left: 3px; font-family: Arial, Helvetica, sans-serif; font-size: .7em; border: 1px solid #678b3f; } table.mytable th { font-family: Arial, Helvetica, sans-serif; font-size: .7em; background: #694; color: #FFF; padding: 2px 6px; border-collapse: separate; border: 1px solid #000; } table.mytable td { font-family: Arial, Helvetica, sans-serif; font-size: .7em; /* border: .1em solid #DDD;*/ border:none; text-align: left; } </style> </head> <body> <div style="position: fixed;width: 1012px;"> <table> <th style="width:72px;position: fixed;"> JO No.</th> <th style="width:72px;position: fixed;"> ETD </th> <th style="width:195px;position: fixed;"> PO No. </th> <th style="width:108px;position: fixed;"> SKU Code </th> <th style="width:220px;position: fixed;"> Description </th> <th style="width:72px;"> Qty Req </th> <th style="width:55px;"> Lines </th> <th style="width:80px;"> Status</th> </table> </div> <div style='overflow:auto; height:200px;'> <table class="mytable"> <?php $sql = "SELECT jo_number, ETD, PO_No, SKUCode, Description, POQty, Priority, Status, line FROM job_order ORDER BY jo_number, ETD"; $res_jo = mysql_query($sql,$con); while($row_job = mysql_fetch_assoc($res_jo)){ // echo "<tbody>"; echo "<tr> <td><input type='text' name='JO_No_' id='JO_No_' value='$row_job[jo_number]' style='border:none;width:auto;' size='10' readonly='readonly'></td> <td><input type='text' name='ETD_' id='ETD_' value='$row_job[ETD]' style='border:none;width:auto;' size='10' readonly='readonly'></td> <td><input type='text' name='PO_No_' id='PO_No_' value='$row_job[PO_No]' style='border:none;' size='32' readonly='readonly'></td> <td><input type='text' name='SKUCode_' id='SKUCode_' value='$row_job[SKUCode]' style='border:none;' size='15' readonly='readonly'></td> <td><input type='text' name='Description_' id='Description_' value='$row_job[Description]' style='border:none;' size='35' readonly='readonly'></td> <td><input type='text' name='POReq_' id='POReq_' value='$row_job[POQty]' style='border:none;width:auto;' size='10' readonly='readonly'></td> <td><input type='text' name='line' id='line' value='$row_job[line]' style='border:none;width:auto;' size='7' readonly='readonly'></td> <td><input type='text' name='priority_' value='$row_job[Priority]' id='priority_' style='border:none;width:auto;' size='11' readonly='readonly'></td> </tr>" ; $sql = "SELECT pcode, lotcode, qty FROM jo_dump WHERE jo_number = '$row_job[jo_number]' ORDER BY date_entry ASC"; $res_dump = mysql_query($sql, $con); while($row_dump = mysql_fetch_assoc($res_dump)){ echo "<tr>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td><input type='text' name='lotcode' value='$row_dump[lotcode]' style='border:none;width:auto;' size='10' readonly='readonly'></td>"; echo "<td><input type='text' name='pcode' value='$row_dump[pcode]' style='border:none;width:auto;' size='15' readonly='readonly'></td>"; echo "<td> </td>"; echo "<td><input type='text' name='qty' value='$row_dump[qty]' style='border:none;width:auto;' size='10' readonly='readonly'></td>"; echo "</tr>"; } } echo "</table>"; echo "</div>"; ?> </body> </html> and I attach the image of output of this code. Thank you Hi All, Prob very simple but here goes. I've a form on a page, which needs a recaptcha field, due to design constraints however, it won't fit. I therefore need it so you fill in the form, click submit, a new window appears with the recaptcha field and a confirmation button. Once you click confirm, the form is processed and the email sent. What's the best way to do this please? The form script has the PHP to handle the emailing side. right ive setup my own messaging feature on my website but it still allowes me to message myself if tried <? }else{ if($to == username){ ?> the whole code so you can get a better understanding <?php session_start(); include_once "includes/db_connect.php"; include_once "includes/functions.php"; logincheck(); $username=$_SESSION['username']; $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'")); if ($fetch->texts < '1'){ echo "<font color=red>You don't have No Texts Left</font><br>"; }elseif($fetch->texts >= '1'){ ?> <body onLoad="goaway();"><? $towho=$_GET['fromper']; $oldmsg=$_GET['oldmsg']; $text=$_POST['text']; $subject=$_POST['subject']; $fsubject=$_GET['fsubject']; $info=mysql_fetch_object(mysql_query("SELECT rank FROM users WHERE username='$username'")); $goody = mysql_query("SELECT `inbox`, `date`, `from` FROM `messages` WHERE `id`='$rep'"); while($success = mysql_fetch_row($goody)){ $ini = $success[0]; $dateon = $success[1]; $fromper = $success[2]; } if(strip_tags($_POST['Send'])){ $text=strip_tags(addslashes($text)); $to = strip_tags(addslashes($_POST['to'])); $rep = $_GET['rep']; if((!$to)){ ?> <p class="style4">Please enter a username!</p> <span class="style4"> <? }else{ if(!$text){?> </span> <p class="style4">You cannot send a blank message!</p> <span class="style4"> <? }else{ if($to == username){ ?> </span> <p class="style4">You cannot send a message to yourself!</p> <span class="style4"> <? }else{ $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$to'"); $username_check = mysql_num_rows($sql_username_check); if ($username_check == 0){ ?> </span> <p class="style4">Invalid Username!</p> <span class="style4"> <? }else{ $date = gmdate('Y-m-d H:i:s'); $sql = mysql_query("INSERT INTO `inbox` (`id`, `to`, `from`, `message`, `date`, `read`, `subject`) VALUES ('', '$to', '$username', '$text', '$date', '0', '$subject');") or die (mysql_error()); $sqll = mysql_query("UPDATE users SET texts = texts-1 WHERE username='$username'"); if(!$sql){ ?> </span> <p class="style4">There has been an error please contact an Admin !</p> <span class="style1"> <? }else{ echo "<table width=300 border=1 align=center cellpadding=0 cellspacing=0 bordercolor=#003300 class=thinline2> <tr> <td height=20 align=center bgcolor=#74CE59 scope=col><span class=style1>Your Message As Been Sent </span></td> </tr> </table>"; }}}}}} ?> Hey Guys, I have followed a tutorial and got a SMS text message script working. Although what i would like to do now is allow a registered user to add another user via a form. This form will contain the users mobile number, email, who its from, and a textarea for the message to send to them in the text message. *** It also stores it into a database. But dont worry about that. I have run into a problem, when i type in a mobile number and an email address and then press send. It doesnt seem to store the email address in the $vars echo (message). **It does echo in the email bit but i wont it to show in the message bit. ** Here is a screenshot. Code: [Select] <?php include 'header.php'; ?> <form name="form1" method="post" action="insert_ac.php"> <table id="formcss" width="100%" border="0" cellspacing="1" cellpadding="3" align="center"> <tr> <td colspan="3"><strong>Insert Data Into mySQL Database </strong></td> </tr> <tr> <td width="71">Name</td> <td width="6">:</td> <td width="301"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Company</td> <td>:</td> <td><input name="company" type="text" id="company"></td> </tr> <tr> <td>Phone</td> <td>:</td> <td><input name="phone" type="text" id="phone"></td> </tr> <tr> <td>Mobile</td> <td>:</td> <td><input name="mobile" type="text" id="mobile"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td>Called</td> <td>:</td> <td><input type="checkbox" name="call" value="training" /> Training <input type="checkbox" name="call" value="business" /> Business <input type="checkbox" name="call" value="legal" /> Legal <input type="checkbox" name="call" value="other" /> Other</td> </tr> </tr> <tr> <td>Patched To</td> <td>:</td> <td> <select name="patch"> <option value="sperkins">S.Perkins</option> <option value="srayson">S.Rayson</option> <option value="strandafil">S.Trandafil</option> <option value="tmoore">T.Moore</option> <option value="lharding">L.Harding</option> <option value="vmitchell">V.Mitchell</option> <option value="achilvers">A.Chilvers</option> <option value="aedwards">A.Edwards</option> <option value="rfrost">R.Frost</option> <option value="ohoogenhout">O.Hoogenhout</option> <option value="pkeily">P.Keily</option> </select> </td> </tr> <tr> <td>Filled out by</td> <td>:</td> <td><input name="user" type="text" id="user"></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> <?php include 'footer.php'; ?> Code: [Select] <?php $host="Localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $name=$_POST['name']; $company=$_POST['company']; $phone=$_POST['phone']; $mobile=$_POST['mobile']; $email=$_POST['email']; $call=$_POST['call']; $patch=$_POST['patch']; $user=$_POST['user']; // Insert data into mysql $sql="INSERT INTO $tbl_name(name, company, phone, mobile, email, call, patch, user)VALUES('$name', '$company', '$phone' '$mobile', '$email', '$call', '$patch', '$user')"; $result=mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; echo "<BR>"; echo "<a href='insert.php'>Back to main page</a>"; } else { echo "ERROR 1"; //This is where the error is. Not sure why it's not working } // close connection mysql_close(); ?> Can anyone see what i've done wrong here? I swear my brain is going to explode if i look over this one more time. Just a simple form trying to submit to the database i am making a private messaging system like hotmails where the message list appears on the left. Then when you click on one of them the box on the right loads the email. The problem is i dont really know how to go about it. Anyone have any pointers? Hi2all! I have one question: A have this page: http://proximabih.com/elitesecurity/test_mapa.html Its on my native lang, but what is important that at the bottom of page is generated google maps static image of dynamic map. Now - how to send, or how to integrate this image to php $body of ph contact form. My idea is to have two pages-first is above link, another is php contact form, so if we have php contact form, on first page maby i need to create SUBMIT button which will by code automaticly put url with poicture in contact form body. I really don have any idea, any help is very appriciate ) I am looking for someone that would be willing to provide the code for a message box that will popup after a PHP file upload completes. It will simply display a message stating that the upload is complete. Thank you in advance for your assistance. Hi I would like to add a 'welcome message' (Hello John Doe, etc.) after successful login. Can this be done best in php? Cheers, visitor Basically, All I want to do is save a .txt (doesn't have to be .txt) to my FTP and PHP simple echos it. The .txt is where a message is stored. But when I write the message my self like this: Hello This is a message. - And then upload it to my FTP, PHP echos it like this "HelloThis is a message". Is there anyway for PHP to notice the 'white space'? --OR-- If you know of a better way to make a message system, then also let me know Thanks, Ollie! 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 |