PHP - Noob Q: Simple Js Alert Post Callback To Php Script
<td> <button onclick="alertdialog()"><span class="glyphicon glyphicon-trash"> </span></button></td>
<script> function alertdialog(){ window.confirm("Are you sure you want to delete this post?"); } </script> This is my code. I need to have a callback to a PHP script when a user decides to delete a post. I think html POST is the most unobtrustive way to do this. What's the easiest / most robust way to send data to a script when the user clicks OK? Appreciated. Mark Similar TutorialsHello, im very green to php and I am having trouble creating a simple log in script. Not sure why this is not working, maybe a mysql_query mistake? I am not receiving any errors but nothing gets updated in the members table and my error message to the user displays. any help is appreciated! here is my php: <?php session_start(); $errorMsg = ''; $email = ''; $pass = ''; if (isset($_POST['email'])) { $email = ($_POST['email']); $pass = ($_POST['password']); $email = stripslashes($email); $pass = stripslashes($pass); $email = strip_tags($email); $pass = strip_tags($pass); if ((!$email) || (!$pass)) { $errorMsg = '<font color="#FF0000">Please fill in both fields</font>'; }else { include 'scripts/connect_db.php'; $email = mysql_real_escape_string ($email); $pass = md5($pass); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$pass'"); $log_check = mysql_num_rows($sql); if ($log_check > 0) { while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $_SESSION['id']; $email = $row["email"]; $_SESSION['email']; $username = $row["username"]; $_session['username']; mysql_query("UPDATE members SET last_logged=now() WHERE id='$id' LIMIT 1"); }//Close while loop echo "You are logged in"; exit(); } else { $errorMsg = '<font color="#FF0000">Incorrect login data, please try again</font>'; } } } ?> and the form: <?php echo $errorMsg; ?> <form action="log_in.php" method="post"> Email:<br /> <input name="email" type="text" /><br /><br /> Password:<br /> <input name="password" type="password" /><br /><br /> <input name="myBtn" type="submit" value="Log In" /> </form> 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> ok..ive done this a million times..i have a working example here and i copied it and amended it for this new project but for some reason i cant get a form to post data to another page. this is the error message i get Notice: Undefined index: username in C:\wamp\www\uni\fyp\site\mobile\login.php on line 16 Notice: Undefined index: password in C:\wamp\www\uni\fyp\site\mobile\login.php on line 17 here is my form code: <form method="post" action="login.php"> <table align="center" cellpadding="0" cellspacing="0"> <tr> <td style="vertical-align:top;">Username: </td><td><input type="text" name="username" value="" /></td> </tr> <tr> <td style="vertical-align:top;">Password: </td><td><input type="password" name="password" value="" /><br /><input type="submit" id="submit" value="Login" /></td> </tr> </table> </form> and here is the code within the login.php where the form should post to $username = $_POST['username']; $password = $_POST['password']; // Help protect against MySQL injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); // Selecting data from database where correct username and password are found $sql="SELECT * FROM customer WHERE username='$username' and password='$password'"; $result=mysql_query($sql) or die(mysql_error()); i cant see anything wrong..been looking for hours...please please help me Hi
I'm new to wordpress and PHP, I'm not a developer and I only understand HTML. All I've learnt so far about wordpress is from youtube, so apologies in advance for all the questions.
In the header where it says "Get Register", i want to change it to just say "Register".
I'm using firebug and Firefox browser to find the file, to edit the above request.
so far, its told me the text i need to edit, is in custom.css?ver=1
on line 329
I found the file custome.css, but how do i edit custom.css?ver=1 please?
Hello, I'm developing a script that includes an admincp. I want to know if anyone knows how to make it so when the administrator goes to the update section of the admin cp, it checks the scripts current version and displays the latest version released, then they have an option to install the latest version, using php to release the files needed with a list of files on the update server. Is there any possible way to do this? This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=343702.0 Hey all, I've been programming with php for about 3 months now and am still out to lunch on a lot of it. I was hoping someone could help me clear up a problem I'm having with my script. It's a simple script that takes a user selection from the previous page ($StarterPackGroup) and executes a list of randomized functions based on the users selection. (There are 4 races to choose from, here's the url to the page that provides the info for $StarterPackGroup for my script. http://www.eardrumvalley.com/backdoor/MINI_TACTICS/Starter_Pack.php Once the user has selected one of 4 races, it takes them to this php script and rolls for their first "pack". I currently only have the "aqua elves" responding, so click on them. Now, I have the page setup so it generates random numbers, and I know the numbers ARE generating, because I see them with an echo command (you will too, they are at the top of the page). However, the problem I'm having, is trying to utilize these random generated numbers in my other functions. ie: I create $UncommonUnit[$i], $CommonUnit[$i], $RareUnit[$i] and $MonsterUnit in the NewStarterPackRoll function.... however, i can't seem to utilize them in my other functions. How do I pass this info to another function? The echo returns the random numbers from $CommonUnit, $UncommonUnit, $RareUnit and $MonsterUnit just fine WITHIN the StarterPackRoll function, but not later on in the AquaElfStarterPack function. Anytime I try to echo the return value of these holders, I get a blank value... I also know the value isn't being passed between functions because none of my if statements are working either. All the units receive a default allocation (Trooper, Hero, Champion, Skel Sprite), if the randomized numbers were passing, these would be giving me other values as well. Please help, I'm convinced there's a simple answer, and I'm just an idiot when it comes to PHP. Lend me a hand! CODING INFO ----------------- THE DATE ENTREE SCREEN - "http://www.eardrumvalley.com/backdoor/MINI_TACTICS/Starter_Pack.php" (BE SURE TO PICK AQUA ELVES, THEY ARE THE ONLY RACE THAT SENDS VALUES) This will bring you to the script page after you submit the selection: THE SCRIPT CODE ON "Open_First_Pack.php" after the data is sent is as follows: (please browse to webpages to see results of code). <?php function RaceCheck($StarterPackGroup) { if ($StarterPackGroup=="AquaElves") { AquaElfStarterPack(); } } function NewStarterPackRoll() { $i = 0; while ($i < 9) { $i = $i + 1; $CommonUnit[$i] = rand(1, 100); echo "" . $CommonUnit[$i] . " "; } $i = 0; while ($i < 4) { $i = $i + 1; $UncommonUnit[$i] = rand(1, 100); } $i = 0; while ($i < 2) { $i = $i + 1; $RareUnit[$i] = rand(1, 100); } $MonsterUnit = rand(1, 100); } function AquaElfStarterPack() { $i=0; echo "<p><b>Commons:</b><br>"; while ($i < 9) { $i=$i + 1; if ($CommonUnit[$i] <= 20) { $OpenedCommon[$i] = "Trooper"; } else if ($CommonUnit[$i] <= 40) { $OpenedCommon[$i] = "Bowman"; } else if ($CommonUnit[$i] <= 65) { $OpenedCommon[$i] = "Sentinal"; } else if ($CommonUnit[$i] <= 80) { $OpenedCommon[$i] = "Horseman"; } else if ($CommonUnit[$i] <= 100) { $OpenedCommon[$i] = "Evoker"; } echo "" . $CommonUnit[$i] . " "; echo "" . $OpenedCommon[$i] . "<br>"; } echo "</p><p><b>Uncommons:</b><br>"; $i=0; while ($i < 4) { $i=$i + 1; if ($UncommonUnit[$i] <= 20) { $OpenedUncommon[$i] = "Hero"; } else if ($UncommonUnit[$i] <= 40) { $OpenedUncommon[$i] = "Archer"; } else if ($UncommonUnit[$i] <= 65) { $OpenedUncommon[$i] = "Courier"; } else if ($UncommonUnit[$i] <= 85) { $OpenedUncommon[$i] = "Knight"; } else if ($UncommonUnit[$i] <= 100) { $OpenedUncommon[$i] = "Conjurer"; } echo "" . $UncommonUnit[$i] . " "; echo "" . $OpenedUncommon[$i] . "<br>"; } echo "</p><p><b>Rares:</b><br>"; $i=0; while ($i < 2) { $i=$i + 1; if ($RareUnit[$i] <= 15) { $OpenedRare[$i] = "Champion"; } else if ($RareUnit[$i] <= 35) { $OpenedRare[$i] = "Sharp Shooter"; } else if ($RareUnit[$i] <= 55) { $OpenedRare[$i] = "Herald"; } else if ($RareUnit[$i] <= 80) { $OpenedRare[$i] = "Eagle Knight"; } else if ($RareUnit[$i] <= 100) { $OpenedRare[$i] = "Enchanter"; } echo "" . $RareUnit[$i] . " "; echo "" . $OpenedRare[$i] . "<br>"; } echo "</p><p><b>Monster:</b><br>"; if ($MonsterUnit <= 25) { $OpenedMonster = "Skeleton Sprite"; } else if ($MonsterUnit <= 45) { $OpenedMonster = "Tako"; } else if ($MonsterUnit <= 75) { $OpenedMonster = "Coral Giant"; } else if ($MonsterUnit <= 100) { $OpenedMonster = "Gryphon"; } echo "" . $MonsterUnit . " "; echo "" . $OpenedMonster . "</p>"; } NewStarterPackRoll(); RaceCheck($_REQUEST['StarterPackGroup']); ?> Hi guys and girls im a new guy on this forums and im here to beg for a favor, for my school assignment i have to make a simple php script and i have no idea how to do that so, here i am what i need is basically a video store rental application that store staff would use. Nothing fancy just that it works. We also got sakila-db to work with and use witch is 30% of my problem if a got to make my own db i would not be quite as confused right now. Can any1 help me because im starting to panic. i apologize if i posted in the wrong place. im including small dijagram of how this thing is supposed to look any help would be appreciated. [attachment deleted by admin] I need help with the attached script. I am using ipage.com to host and when I log in with credentials that have been placed in the database I just get the login prompt coming up every time. There is no die action that says access failed or anything. I have been trying to insert data into my database thru php script with no luck. I think its has to do with not being able access my database. My question is when I use MySQL command client and enter the password and get mysql> does that mean I can use that password to access my databases as long as I point to the correct database with the mysqli_connect function. I dont think I fully understand how this works. I have everything stored on my local computer and I use "localhost" in mysqli_connect function. I'm trying to make a newspaper page - I have a simple code but when i hit submit nothing happens, just page refreshes. Help would be great! Code: Code: [Select] <?php session_start(); include "includes/db_connect.php"; include "includes/functions.php"; logincheck(); $username=$_SESSION['username']; $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); $above = mysql_query("SELECT * FROM users WHERE username='$username'"); $info = mysql_fetch_object($above); $admin=$info->editor ; if($admin !=1){ echo"<center> This information is limited to Editors only!"; }else{ if ($_POST['Submit']){ $edition = $_POST['edition']; $news = $_POST['news']; $title = $_POST['title']; $by = $_POST['by']; $date = gmdate('Y-m-d h:i:s'); mysql_query("INSERT INTO `paper` ( `edition` , `news` , `title` , `by` , `date` ) VALUES ( '', '$edition', '$news', '$title', '$by', '$date' )"); echo "Article has been added"; } ?> <form name="form1" method="post" action=""> <table width="450x" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" class="Main"> <tr class="Tableheading"> <td class="TableHeading">Add an Article</td></tr> <tr> <td class="TableArea" align="center">Edition: <input name="edition" type="text" id="edition" value="" size="30"> </td></tr> <tr> <td class="TableArea" align="center">Article: <input name="news" type="text" id="news" value="" cols="80" rows="5"> </td></tr> <tr> <td class="TableArea" align="center">Title: <input name="title" type="text" id="title" value="" size="30"> </td></tr> <tr> <td class="TableArea" align="center">Author: <input name="by" type="text" id="by" value="" size="30"> </td></tr> <tr><td class="TableArea" align="center">Add this article: <input name="submit" type="submit" class=button id="submit" value="Add Article"><br> </td></tr> </table> </form> <? } ?> Hey all. I am a php newbie. Just starting to get my feet wet. So my issue is this. I have a MySQL database table called "blog" Within that table are "ID, photo_id, post_head, post_body" I have connected to the database via php and have been successfully echoing the fields onto my page. But the problem is that I don't know how to create a loop. I need it to show the latest post (biggest ID #) first then display descending down. Here is my code. As you can see I'm echoing the same variables and logically its displaying the SAME post 2 times. Any help would be just great! <table width="925" border="0" cellspacing="0" cellpadding="0"> <tr> <? $data = mysql_query("SELECT * FROM blog ORDER BY id DESC") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { $id = $info['ID']; $photo_id = $info['photo_id']; $post_head = $info['post_head']; $post_body = $info['post_body']; } ?> <!-- POST 1 START --> <td width="180"> <img src="<? echo $photo_id ?>" /> </td> <td id="box_bg2" class="padding_state" width="275" valign="top"> <br /> <font id="post_head"> <? echo $post_head ?> </font> <br /> <font id="post_body"> <? echo $post_body ?> </font> </td> <td width="15"> </td> <!-- POST 2 START --> <td width="180"> <img src="<? echo $photo_id ?>" /> </td> <td id="box_bg2" class="padding_state" width="275" valign="top"> <br /> <font id="post_head"> <? echo $post_head ?> </font> <br /> <font id="post_body"> <? echo $post_body ?> </font> </td> </tr> </table> Ok so I already have a "post" action URL, here it is below. <form method="post" action="http://survey.leisuretrends.com/RemoteSurvey.asp?survey=321&survey_version=1330"> The idea is to put a simple e-mail form on my personal website: And have the post action to go to the URL above (its a marketing company for email submissions / newsletters) Here is what I have so far, but I know something is not right: Quote <form> <input type="text" /> <input type="submit" /> <form method="post" /> <form action="http://survey.leisuretrends.com/RemoteSurvey.asp?survey=321&survey_version=1330"/> </form> Any help would be greatly appreciated. Thank you for your patience with me I have the simple code below which seems to have worked on forms from a contact page on a website. Unfortunately, it seems to only send the forms if all fields are entered. I have played with the code but cannot seem to get it to send any field that has been completed on submit. Can someone help please? <?php $emailAddress = "bigL@gmail.com"; $thankyouPage = ""; session_start(); if (!empty($_POST)) { foreach ($_POST as $key=>$value) { $_POST[$key] = stripslashes($_POST[$key]); $_POST[$key] = htmlspecialchars($_POST[$key],ENT_QUOTES); } } if (isset($_POST['send']) AND isset($_SESSION['msgCount'])) { if ($_SESSION['msgCount'] >= "3") $alert = "Only 3 messages can be s +ent per session."; if (empty($alert)) { $_SESSION['msgCount']++; putenv('TZ=EST5EDT'); // eastern time $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n" +; $message = "<table cellpadding='5' border='1'>"; foreach ($_POST as $key => $value) if (!preg_match("(^send)",$key)) { $value = wordwrap($value,65,"<br />"); $message .="<tr><td><b>$key</b></td><td>$value</td></tr>"; } $message .= "</table>"; $message .= "<br />Time of the message: ".date(" F d h:ia")."<br +/>"; $message .= "IP Address: ".$_SERVER['REMOTE_ADDR']."<br />"; $message .= "Hostname: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])."< +br />"; $subject = $_SERVER['HTTP_HOST']." Message"; mail($emailAddress,$subject,$message,$headers); if (!empty($thankyouPage)) { header('location: '.$thankyouPage); die(); } unset($_POST); $alert = "Your enquiry has been sent, we will respond as soon as p +ossible."; } } if (!isset($_SESSION['msgCount'])) $_SESSION['msgCount'] = 0; ?> Can I post my "Add a Comment" script here to get help improving it? Debbie Hi can someone pls help, im tryin a tutorial but keep getting errors, this is the first one i get after registering. You Are Registered And Can Now Login Warning: Cannot modify header information - headers already sent by (output started at /home/aretheyh/public_html/nealeweb.com/regcheck.php:43) in /home/aretheyh/public_html/nealeweb.com/regcheck.php on line 46 I have a page, that upon post, does some logic, this logic can take 1-30 minutes... Now sometimes I will get a "Page time out"....and others i wont... even if im requesting the same data. I used it successfully everytime on my stock xp, with ie8 But cant get it to work on my VISTA WIN7 x64 machins, and another xp machine, after about 1-5 min it says "page time out", then i test it on my stock xp machine, and it can run for 45 min, or runs until everything is finsihed and shows the page. Any ideas? Hi all, Since twitter changed the way they allow people to post, my simple php script to grab the $_POST data from an input and post it to my twitter profile has broken. I've been reading up on Oauth, but none of the documentation is clear at all. It's quite complex, in fact - they assume you are creating a full app, which I am not - I just want to flick some text to twitter. I just want to pass a simple string variable to my account - can anyone help me with how to do this? All help appreciated. WoolyG Is there a quick an easy way to test my php scripts without creating an html form and specifying values that I post to my php script? Maybe a firefox plugin or some tool that can be used to do it quicker? In the long haul, quicker, not just one time |