PHP - Pure Php Back Button
I have found a point in my site where the user may wish to go back a page. Using the back button in the browser works perfectly fine. However, for aesthetical reasons and for "obvious function" reasons i need to create a button on the page which goes back a step in the browsers history.
I know I can do this with Javascript, but I would rather get it done with php first. Therefore is it possible to create a back button in PHP. The back button in question will go back one step in the browsers history to the same .php it is currently on but in a previous state. I found this from google, http://www.webmasterworld.com/forum88/870.htm, but then found there was some js in the answers. I cannot find any other posts similar to this in php freaks Similar Tutorials
I Need To Show Data After Pressing Browser's Back Button [accidentally Pressed Enter Instead Of Tab]
Please, take a look to the following code.After clicking Next it goes to overview.php.Why when I click back on my browser to return to this page again, it is not returning back? When I click back I receive "Confirm Form Resubmission" message. After refreshing page it loads page. I guess problem is in "session_start();" part. Something to do with cookies. Please, help me it is very urgent for me. <?php session_start(); echo "<html> <head> <title>Hello World</title> <meta http-equiv='Content-Type' content='text/html; charset=Windows-1252'/> </head>"; require_once ('functions.inc'); if(!isset($_POST['userid'])) { echo "<script type='text/javascript'>"; echo "window.location = 'index.php'"; echo "</script>"; exit; }else{ session_register("userid", "userpassword"); $username = auth_user($_POST['userid'], $_POST['userpassword']); if(!$username) { $PHP_SELF = $_SERVER['PHP_SELF']; session_unregister("userid"); session_unregister("userpassword"); echo "Authentication failed " . "Please, write correct username or password. " . "try again "; echo "<A HREF=\"index.php\">Login</A><BR>"; exit; } } function auth_user($userid, $userpassword){ global $default_dbname, $user_tablename; $user_tablename = 'user'; $link_id = db_connect($default_dbname); mysql_select_db("d12826", $link_id); $query = "SELECT username FROM $user_tablename WHERE username = '$userid' AND password = '$userpassword'"; $result = mysql_query($query) or die(mysql_error()); if(!mysql_num_rows($result)){ return 0; }else{ $query_data = mysql_fetch_row($result); return $query_data[0]; } } echo "hello"; echo "<form method='POST' name='myform' action='overview.php'>"; echo "<input type='submit' value='Next'>"; echo "</form>"; ?> I am getting strange behavior after a user submits a comment. After they comment on an article, I display a success message with two buttons: "Return to Article" and "Go to Home Page" Each button seems to work, and I was even able to "Return to Article" and then hit my browser's Back button to return the original "You Comment was Added" message, but if I hit the Back button after hitting "Go to Home Page" I got this error... Quote Notice: Undefined index: pageTitle in /Users/user1/Documents/DEV/++htdocs/01_MyProject/add_comment.php on line 39 Call Stack On Line 39 I have this code... Code: [Select] // Set Page Title. $pageTitle = $_SESSION['pageTitle']; It seems to me that if a user hits the Back button in general it will often cause problems, so is there a way to handle this?? I'm not exactly certain is causing the error above in the first place since my SESSION should be intact.... Debbie I have tried to create a back button, but I have not reached the correct solution. I log into first page (index.php) and then you will get two new buttons that brings me to two different pages. Then I want to come back to the login page, the session is gone and I have to log in again. I want to remain logged in when I get to the index page and be able to see the two buttons. I tried different things such as: Code: [Select] <input type="button" value="Return to previous page" onClick="javascript:history.go(-1)" /> Code: [Select] <?php $referer = $_SERVER['HTTP_REFERER']; if (!$referer == '') { echo '<p><a href="' . $referer . '" title="Return to the previous page">« Go back</a></p>'; } else { echo '<p><a href="javascript:history.go(-1)" title="Return to the previous page">« Go back</a></p>'; } ?> But that's not what I'm thinking about. How can I solve this? index.php <?php session_start(); if(isset($_POST['LoutBtn'])) { session_destroy(); } if(isset($_POST['LoginBtn'])) { //convert a string to all lower case letters. //if user gives username with big letters still can login. $user = strtolower($_POST['username']); $pass = $_POST['password']; if($user == 'admin' && $pass == '123') { $_SESSION['LogedIn'] = true; { print('Welcome admin'); ?> <table width="50" align="right" cellpadding="2" cellspacing="2"> <form method="POST" action="panel.php"> <tr> <td><input type="submit" value="add post" name="PnlBtn" /></td> </tr> </form> <form method="POST" action="stat.php"> <tr> <td><input type="submit" name="showstat" value="visitorlog" /></td> </tr> </form> </table> <?php } } elseif (empty($user) || empty($pass)) { print('<font color="#FF0000">Please fill in username and password!<br/></font>'); } elseif ($_POST['username'] != 'admin'){ print('<font color="#FF0000">wrong username<br/></font>'); } elseif ($_POST['password'] != '123'){ print('<font color="#FF0000">wrong password<br/></font>'); //elseif { // print('<font color="#FF0000">The User Name And/Or Password is incorrect! // Please try again...<br/></font>'); //print('<a href="index.php">Back</a>'); } } ?> <?PHP /* define the blog content file name */ $filename = "myBlogContent.txt"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form method="post" action="index.php" > <table width="300" border="1" align="right" cellpadding="2" cellspacing="2"> <tr> <td width="150">UserName:</td> <td> <input type="text" name="username" size="20" /> </td> </tr> <tr> <td width="150">Password</td> <td><input type="password" name="password" size="20" /></td> </tr> <tr> <td><input type="submit" value="Login" name="LoginBtn" /> </td> </tr> <tr> <td><input type="submit" value="Logout" name="LoutBtn" /></td> </tr> </table> </form> <!-- CONTENT DIV --> <div style="position:absolute; left: 100px; top: 100px; width: 400px;"> <?PHP /* check to see if the file exists */ if (!file_exists($filename)) { echo "The Blog Is Empty"; }else{ /* get the file lines into an array */ $BlogArray = file($filename); /* count the number of blog entries */ $count = count($BlogArray); $i=0; while($i<$count) { $new_array = explode("|", $BlogArray[$i]); echo "Posted by: " . $new_array[1] . "<br>"; echo "Posted on: " . date("m/d/y", time($new_array[0])) . "<br>"; echo "Title: " . $new_array[2] . "<br>"; echo $new_array[3] . "<hr>"; $i ++; } } ?> </div> </body> </html> panel.php <?php session_start(); if ($_SESSION['LogedIn'] == false) { $redirect = "Location: " . $_REQUEST['LoginBtn'] . "index.php"; echo header($redirect); } elseif ($_SESSION['LogedIn'] == true) { echo "welcome"; } //if(isset($_POST['LoutBtn'])){ //{ // session_destroy(); // header ('Location: index.php'); //if ($_SESSION['LogedIn'] == true) //{ // print('<h1>Welcome admin</h1>'); // } //else //{ // session_destroy(); // header ('Location: index.php'); //} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="content.php" method="post"> <table> <tr><td>Blog entry posted by (Your name): </td><td><input type="text" name="who" size="20" maxlength="20" value=""></td></tr> <tr><td>Title of this blog entry: </td><td><input type="text" name="title" size="40" maxlength="80" value=""></td></tr> <tr><td>Content: </td><td><textarea name="content" rows="5" cols="40"></textarea></td></tr> <tr><td clospan="2"><input type="submit" value="Submit"></td></tr> <tr><td clospan="2"><input type="submit" name="showstat" value="visitorlog" /></td></tr> <tr><td clospan="2"><input type="submit" value="Back" name="back" /></td></tr> </table> </form> </body> </html> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=350924.0 Hey, I made a register page and its all working great. I want to have a "Back" button when the user submits the form if password1 & password2 do not match or username allready exists. But trying to put one in after the echo command isn't working for me. Can anyone help? Heres the error I recieve: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/jamiew90/public_html/Staff/register.php on line 49 Heres line 49 & the surrounding lines incase needed, line 49 is the one beginning with echo: //none were left blank! We continue... if($password != $cpassword) { // the passwords are not the same! echo "<br><br><b>Passwords do not match</b> <p> <FORM><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;;"> </FORM>";"; }else{ // the passwords are the same! we continue... Is it possible to even add a back button after echo? Thanks for the help - Jamie So, I just don't know where to post this question. I've written a quiz program where 50 English vocab words are pulled from a dB and displayed on one page with the order scrambled. My students then type the Spanish translation for each. When they submit the form the next page grades their work. They have to get a 90 or better for the grade to be automatically recorded, so I want them to click the back button and go back and make corrections. The problem is when they use a Chrome browser and click the back button the program re-sorts the order of questions. It leaves the order of their answers the same. So what they answered for number 1 is still in the field for number 1, but the questions (the English vocab word) is different. Chrome does this consistently so I thought this was a Chrome issue only. Then one of my students said the same thing happened to her when using Safari. So here is my question, how can I stop Chrome (or any other browser) from re-running my server-side PHP scripts (re-sorting the vocab array) when clicking the back button?
Here is the code for students taking the quiz:
<form method="post" action="portal.php?load=vquiz_grade" style="margin-left: 50px; line-height: 30px;">
$max = $count-1;
?>
//print "<br>";
<input type="hidden" name="max" value="<?print $max?>"> And here is the code showing them what they missed.
<?
// Total grade
print "You missed ".$wcount." words.<br>";
print "<table>";
// Grade response and set color
if ($wrong == 1){ if ($grade >= 90){
$query = "SELECT * FROM inno_vocab_assignments WHERE key_code = '$key_code' AND uname = '$secure_uname' AND teacher = '$teacher'";
// Prevent student from changing vocab list so as to do an easier list
// Insert grade
}
Thank you!
I have made a website with a custom scroll bar and a back to top button. For some reason the back to top button doesn't show up. Code is below:
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Adding a dynamic "Back To Top" floating button with smooth scroll</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> <style> /* For the "inset" look only */ html { overflow: auto; } body { position: absolute; top: 8px; left: 8px; bottom: 8px; right: 1px; padding: 10px; overflow-y: scroll; overflow-x: hidden; } /* Width of bar */ ::-webkit-scrollbar { width: 8px; } /* Track */ ::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); -webkit-border-radius: 10px; border-radius: 10px; } /* Handle */ ::-webkit-scrollbar-thumb { -webkit-border-radius: 10px; border-radius: 10px; background: rgba(255,0,0,0.8); -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); } ::-webkit-scrollbar-thumb:window-inactive { background: rgba(255,0,0,0.4); } </style> <style> div#page { max-width: 900px; margin-left: auto; margin-right: auto; padding: 20px; } .back-to-top { position: fixed; bottom: 1em; right: 0.5em; text-decoration: none; color: #000000; background-color: rgba(235, 235, 235, 0.80); font-size: 12px; padding: 0.8em; display: none; } .back-to-top:hover { background-color: rgba(135, 135, 135, 0.50); } </style> </head> <body> <div id="page"> <!-- [banner] --> <header id="banner"> <hgroup> <h1>Adding a dynamic "Back To Top" floating button with smooth scroll</h1> </hgroup> </header> <!-- [content] --> <section id="content"> <h1>The first heading</h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nec felis sed velit auctor luctus id quis arcu. Ut dui augue, euismod nec justo a, pretium consequat nisi. Vivamus dictum nec quam in sollicitudin. Nullam non augue at risus condimentum consequat eu ut sem. Ut quis tortor quam. Nulla ullamcorper in metus egestas sagittis. In rhoncus feugiat sagittis. Cras eu arcu dui. Nulla non urna varius, facilisis sapien quis, tristique urna. </p> <h2>The first sub-heading</h2> <p> Duis tincidunt eleifend felis ac porttitor. Aenean facilisis elit eget orci vulputate scelerisque. Nulla justo sem, fringilla nec gravida vel, sollicitudin vitae libero. Donec vitae consequat lorem. Cras eros nunc, varius id dictum sit amet, posuere quis augue. Vivamus quis ipsum eget lectus porta vestibulum. Sed malesuada id orci eu rhoncus. Proin eleifend lacus non libero facilisis interdum. </p> <h2>The second sub-heading</h2> <p> Nulla luctus lorem et justo posuere, vitae ornare elit accumsan. Donec semper tincidunt lacus ut sagittis. Donec nec adipiscing nunc, quis rutrum tortor. Vivamus aliquam orci nulla, non ornare mauris eleifend et. Aliquam erat volutpat. Phasellus id nunc sapien. Suspendisse luctus pharetra lorem, quis scelerisque eros ultricies in. Vivamus hendrerit fermentum justo eget sagittis. Pellentesque cursus at turpis id cursus. Pellentesque sed rhoncus enim. Nam et ante feugiat, luctus enim in, tincidunt lectus. In feugiat neque quam. Curabitur mi ante, dictum non aliquam placerat, suscipit sed sem. Integer dictum, nulla vitae accumsan dignissim, augue justo laoreet diam, quis semper lectus orci vel mi. </p> <h3>The first sub-sub-heading</h3> <p> Vestibulum mollis elementum libero a blandit. Fusce placerat odio quis euismod elementum. Maecenas rhoncus quam viverra odio fringilla blandit. Curabitur erat mi, malesuada ac tempor eu, tincidunt vitae erat. Nunc consequat faucibus feugiat. Integer ornare dui metus, sed consectetur erat vulputate a. Sed porttitor eu magna in aliquet. Cras quis tempus lacus, ac fermentum lorem. </p> <h1>The second heading</h1> <p> Nullam dignissim nibh ac eros iaculis, quis aliquam nibh lacinia. Donec et ullamcorper nunc. Sed convallis aliquet ullamcorper. Donec non leo enim. Ut orci ante, viverra fringilla lorem nec, pretium volutpat lorem. Phasellus elit arcu, posuere at nibh at, facilisis adipiscing dolor. Duis hendrerit metus at turpis congue ornare. Aliquam orci nisi, malesuada at adipiscing non, pharetra a lectus. Mauris in rhoncus ipsum, et sagittis nulla. Duis laoreet luctus lorem, at malesuada sem bibendum at. Pellentesque ultrices massa eget lacus tempus, id ornare lacus fermentum. Sed id fermentum tellus. Suspendisse tincidunt posuere arcu quis fermentum. </p> <h2>The third sub-heading</h2> <p> Phasellus vitae lacinia sapien. Nam eget congue lorem. Donec viverra tortor eget tellus iaculis interdum. Vivamus sollicitudin egestas auctor. Vivamus sit amet justo sit amet eros sodales egestas. Nulla nec pharetra metus. Integer rutrum, ipsum in dignissim scelerisque, arcu est adipiscing tortor, nec varius eros mauris vel augue. In condimentum lobortis eros, sed facilisis neque imperdiet vel. Nullam ut commodo lectus, a luctus mi. Aliquam varius quis tortor a interdum. Aliquam erat volutpat. Nam pellentesque augue enim, eget posuere mi ultrices sodales. Vivamus vel varius quam. Donec sed ante placerat sapien consequat facilisis. Fusce vestibulum ipsum urna, nec tincidunt lacus hendrerit quis. Donec ornare dignissim risus. </p> <h2>The fourth sub-heading</h2> <p> Ut mauris mauris, porta bibendum dictum id, porttitor eu odio. Nam posuere in dui vitae pellentesque. Praesent commodo eros mattis posuere hendrerit. Suspendisse felis tellus, laoreet vitae erat non, laoreet gravida quam. Phasellus a augue non leo venenatis tempus. Curabitur ornare purus a mollis vulputate. Quisque vulputate euismod enim sed elementum. Duis id urna iaculis felis consequat vulputate. Mauris sollicitudin, leo eu sollicitudin porttitor, purus lacus sodales ipsum, vitae lobortis velit libero at libero. </p> <h1>The third heading</h1> <p> Quisque iaculis magna ac risus posuere ultricies. Sed tincidunt, sem ac pellentesque fringilla, sapien purus sagittis odio, eget aliquam ante lorem ac risus. In euismod dignissim leo ut eleifend. Proin accumsan velit quam. Phasellus sollicitudin nulla ligula, sit amet mollis lectus pellentesque consectetur. Nunc non dictum ante, fringilla lobortis nulla. Nullam ullamcorper volutpat velit, ut laoreet justo pellentesque ornare. Praesent aliquet eros eu magna sodales, ac pharetra erat dignissim. Nulla pulvinar neque at fermentum eleifend. </p> <h2>The fifth sub-heading</h2> <p> Praesent dictum interdum condimentum. Suspendisse in tortor blandit, lobortis libero eu, cursus libero. Donec vulputate ligula sit amet arcu porta imperdiet. Nam sodales, justo eu eleifend placerat, dui eros suscipit mi, quis congue dolor velit vitae nisi. Pellentesque mollis felis est. Etiam vitae justo laoreet, rutrum felis sed, porttitor dui. Sed cursus tincidunt turpis. Maecenas gravida commodo urna eget hendrerit. Ut suscipit mi sit amet turpis euismod, luctus suscipit turpis egestas. </p> <h1>The fourth heading</h1> <p> Mauris malesuada eros ac nisl pretium, at vehicula sem porttitor. Vestibulum porta erat leo, nec posuere enim pellentesque vel. Praesent libero est, laoreet quis scelerisque nec, egestas vel enim. Vivamus quis vulputate sapien. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vivamus consequat ligula lectus, sed fermentum elit auctor vitae. Duis iaculis sagittis est sit amet semper. Morbi rutrum fermentum vulputate. Proin tincidunt elementum sem, a faucibus dui malesuada sit amet. Vivamus vel enim laoreet, iaculis nunc ac, tristique nisl. Nulla consequat arcu et dolor porta, non ullamcorper augue pharetra. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer sed nibh lectus. Sed pulvinar nunc magna, eget placerat mi pharetra ac. Vestibulum hendrerit, nulla nec vestibulum aliquam, arcu tortor blandit ipsum, eget sollicitudin nulla tellus quis libero. Duis sodales fringilla lacus vel auctor. </p> <h2>The sixth sub-heading</h2> <p> Vivamus erat turpis, condimentum vitae neque sit amet, tincidunt malesuada odio. Mauris mollis ante vitae quam condimentum lobortis. Integer sodales odio sit amet metus tempus, vel dignissim libero sagittis. Suspendisse ornare libero elit, quis sollicitudin leo pellentesque id. Sed pharetra mattis sapien nec condimentum. Mauris convallis arcu eget massa fringilla, nec pellentesque dolor semper. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum vitae odio a sem iaculis tempor. Fusce placerat viverra lorem mollis fermentum. Sed porta sit amet sapien eu venenatis. </p> <h3>The second sub-sub-heading</h3> <p> Aenean ut ipsum ultrices, sollicitudin massa quis, bibendum magna. Sed id porttitor diam, et vestibulum tortor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus vel magna dolor. Etiam cursus nibh ligula, id vestibulum metus varius feugiat. Etiam vitae dolor ligula. Aliquam eu consectetur lorem. Quisque nulla nulla, facilisis semper laoreet non, eleifend in dolor. </p> <a href="#" class="back-to-top"><span class="glyphicon glyphicon-chevron-up"></span></a> </section> <script> jQuery(document).ready(function() { var offset = 220; var duration = 500; jQuery(window).scroll(function() { if (jQuery(this).scrollTop() > offset) { jQuery('.back-to-top').fadeIn(duration); } else { jQuery('.back-to-top').fadeOut(duration); } }); jQuery('.back-to-top').click(function(event) { event.preventDefault(); jQuery('html, body').animate({scrollTop: 0}, duration); return false; }) }); </script> </div> <!-- [/page] --> <script src="//code.jquery.com/jquery.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=321154.0 not sure if this will find an answer but I am posting anyway. Any help is appreciated....my coder has left the team and no matter how I invite her to come and do some bug squashing, her new schedules won't fit a re-visit into my little aplication...I am eager to delve into the codes at my very low knowledge of php. I have initiated reading and is still trying to teach myself...but of course not as fast as the app needs the patch...here's the meat: Hi, I have set up 2 php pages page 1 - add_entry2.php In this page I have a invoice table created where I can dynamically add/delete rows. This has a View Bill button which takes me to page 2- add_entry3.php In this page it shows up the rows added in page 1 in read only format, so if the user wants to modify the data that he/she entered then he must Click on <back> that i have provided in the page 2 which will direct him to page 1 Now the problem starts here on click of Back the dynamically added rows dissappear..which is frustrating..I know its something to do with my code..but can anyone help me fix it. One more thing is that i dont want to store the data into DB till the finalise button is clicked on page 2 so that means till page 2 is submitted nothing goes to DB from Page 1. I am able to retain values if I use the code Code: [Select] <form action="add_entry2.php" name="eval_edit" method="post" format="html"> i,e if I submit back to the same page and retrieve values form $_POST but If I use the code Code: [Select] <input type="button" value="Back" onClick="history.go(-1);return true;">to get back to add_entry2.ph it looses all the values. Is there any other way to code the BACK link retaining my $_POST values(Do you think $_SESSION would work in this case?) I'm trying to convert a grayscale image to pure black and white in php using the GD library. The purpose would be to detect the cervical cells within the image. I'll leave the php code and a matlab one (i wrote this code in matlab and i'm trying to obtain the same result in php). Basically, im having troubles accessing each individual pixel's color and modifying it. MATLAB: clear all, clc, close all; I = imread('celule.jpg'); imshow(I) title('original'); a=rgb2gray(I); figure; imshow(a) title('grayscale'); s=size(a); for i=1:s(1) for j=1:s(2) if a(i,j)>190 a(i,j)=0; else a(i,j)=255; end end end figure; imshow(a) title('pure black and white'); PHP: <?php $im = imagecreatefromjpeg("celule.jpg"); function imagetograyscale($im) { if (imageistruecolor($im)) { imagetruecolortopalette($im, false, 256); } for ($c = 0; $c < imagecolorstotal($im); $c++) { $col = imagecolorsforindex($im, $c); $gray = round(0.299 * $col['red'] + 0.587 * $col['green'] + 0.114 * $col['blue']); imagecolorset($im, $c, $gray, $gray, $gray); } } imagetograyscale($im); //imagefilter($im, IMG_FILTER_CONTRAST, -255); //i'm not looking for this effect header('Content-type: image/jpeg'); imagejpeg($im); $C = imagesx($im); //width $L = imagesy($im); //height echo "Dimensiuni imagine: latime $C, inaltime $L <br>"; //scanning through the image for($x = 0; $x < $L; $x++) { //each line for($y = 0; $y < $C; $y++) { //each collumn // pixel color at (x, y) $color = imagecolorat($im, $y, $x); $color = imagecolorsforindex($im, $color); //getting rgb values $RED[$x][$y] = $color["red"]; //each rgb component $GREEN[$x][$y] = $color["green"]; $BLUE[$x][$y] = $color["blue"]; } } ?> image "celule.jpg": https://i.ibb.co/6Ffj6sc/celule.jpg I have following piece of code below, and I would like to be able to express it pure SQL, something that could go into a .sql file :
$request_string='SELECT topic_forum_id FROM topic_table WHERE topic_id= 2014'; $query=database->prepare($request_string); $query->execute(); $data=$query->fetch(); $query->closeCursor(); $forum=$data['topic_forum_id']; $request_string='INSERT INTO post_table (post_topic,post_forum) VALUES (2014,:forum)'; $query=database->prepare($request_string); $query->bindValue(':forum',$forum,PDO::PARAM_INT); $query->execute(); $data=$query->fetch(); $query->closeCursor();Is it possible ? Friends I am new to php and i have to submit my coursework in php by 3rd dec, I stuck at one place where i have to upload multiple photo and one can see all the photo he has uploaded and can edit or delete that photo so i have done uploading now i am showing those pics in table by running loop and generating tr and td but now i have two buttons with each row edit and delete now when i clicked on one delete or edit that pic should be delete or give text box to edit description of pic, Please help me how to do that....... Hey everyone. So lately I've been searching for someone to do this for me but I figure if I learned it myself it'd be much more helpful to me in the future. I run a gaming clan, and we have a roster. You can view it he http://www.zealotgam...s.php?pageid=15 Obviously, you can see a few things. The default page lists all our staff. That is very easy, and not really the part I need help with. The help begins with the games list you see at the side. When you click a game, it lists all users who have that Game listed as their Main Game in a profile field, and lists other info, such as their rank, In-Game contact (which is another profile field) and join date/last active. The games are also themselves divided into categories. Our code is relatively simple. We keep a manual array of info that keeps these together you can see below: // Define Games and Lists // $gameslist = array(); //SETUP $gamelist[] = array("Game Name","urlshortcode","Name of In-Game Name or Account", "field# for that profile field"); $gameslist[] = array("Battlefield 4 (PS4)", "bf4ps4", "PlayStation ID", "field7"); $gameslist[] = array("Counter Strike: Global Offensive (EU)", "csgoeu", "Steam ID", "field8"); $gameslist[] = array("Counter Strike: Global Offensive (NA)", "csgona", "Steam ID", "field8"); $gameslist[] = array("Elder Scrolls Online (NA)", "esona", "Main Character", "field45"); $gameslist[] = array("League of Legends (EUNE)", "loleune", "Summoner Name", "field12"); $gameslist[] = array("League of Legends (EUW)", "loleuw", "Summoner Name", "field31"); $gameslist[] = array("League of Legends (NA)", "lolna", "Summoner Name", "field32"); $gameslist[] = array("League of Legends (OCE)", "loloce", "Summoner Name", "field47"); $gameslist[] = array("Minecraft", "mc", "Username", "field14"); $gameslist[] = array("Smite (EU)", "smiteeu", "Smite Account", "field22"); $gameslist[] = array("Smite (NA)", "smitena", "Smite Account", "field22"); $gameslist[] = array("Titanfall", "tfall", "Origin ID", "field29"); $gameslist[] = array("WildStar (EU)", "wseu", "Main Character", "field48"); $gameslist[] = array("WildStar (NA)", "wsna", "Main Character", "field48"); $gameslist[] = array("World of Tanks (EU)", "woteu", "WarGaming.NET ID", "field46"); $gameslist[] = array("Other Game", "other", "", ""); // Game Type Categories $gamecats = array(); // ADD the # of the game in the list above (starting from 0) to the appropriate category array number list. $gamecats[] = array("Divisions",array(4,5,6)); $gamecats[] = array("Guilds",array()); $gamecats[] = array("Gaming Groups",array()); $gamecats[] = array("Divisions in Development",array(0,1,2,3,7,8,9,10,11,12,13,14)); $gamecats[] = array("Miscellaneous",array(15)); This gets tedious to keep track of manually, and my admins with no programming experience can barely understand what is happening. The listing of users is very easy, and I do not need any help with that. What I would like to add is a manager in the admin panel where you could save the information listed above to a table such as PREFIX.games. I imagine having several drop down boxes. A mockup is below: I'd then Like a list of games that includes these rows in the table with a [ ] Remove checkbox. I do not know how to add this to the admin panel and would love guidance on how to begin doing this. The sorting would go by Game Status (the second array in my php code) then Alphabetical. This would go a long way in helping my staff edit this list themselves. Any help would be appreciated. Skype: j.c.will my be better to work personally with me. And we're back online... again! It may have taken 3-4 days, but we're back.
I have the following code. Before back button was working. Now don't understand what happend but when I click Back button I receive "Webpage has expired" window in my browser. What may be the reason? Code: [Select] <html> <head> <title>Økern Frukt og Grønt</title> <link href="calendar/calendar.css" rel="stylesheet" type="text/css" /> <script language="javascript" src="calendar/calendar.js"></script> <style type="text/css"> textarea { resize: none; } </style> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252"/> </head> <?php if(!isset($_POST['userid'])) { echo "<script type='text/javascript'>"; echo "window.location = 'login.html'"; echo "</script>"; exit; } require_once ('functions.inc'); require_once('calendar/classes/tc_calendar.php'); global $default_dbname; $link_id = db_connect($default_dbname); mysql_select_db("okern", $link_id); $letters1 = array ("A1", "B1", "C", "D","E", "F", "G", "H","I", "J", "K", "L", "M", "N", "O", "P","Q", "R", "S", "T","U", "V", "W", "X", "Y", "Z", "&#198", "&#216", "&#197"); $letters = array_merge(range("A", "Z"), array("&#38;#198", "&#38;#216", "&#38;#197")); echo "<table border='0' align='center'> <tr> <td colspan=3><b><center>Du har valgt f&#248lgende produkter</center></b></td> </tr> <tr> <th align=left>Produkt</th> <th align=left>Antall</th> <th align=left>Enhet</th> </tr>"; echo "<form method='POST' action='order.php'>"; $userid = $_POST['userid']; echo "<INPUT TYPE='hidden' NAME='userid' VALUE='$userid'>"; foreach($letters as $letter) { if(isset($_POST[$letter])) { $selected = $letter . '1'; $antall = $letter . '2'; $enhet = $letter . '3'; echo "<tr>"; echo "<td>" . "<INPUT TYPE='hidden' NAME='$selected' VALUE='$_POST[$selected]'>" . "$_POST[$selected]" . "</td>"; echo "<td>" . "<INPUT TYPE='hidden' NAME='$antall' VALUE='$_POST[$antall]'>" . "$_POST[$antall]" . "</td>"; echo "<td>" . "<INPUT TYPE='hidden' NAME='$enhet' VALUE='$_POST[$enhet]'>" . "$_POST[$enhet]" . "</td>"; echo "</tr>"; } } for ($i = 1; $i < 400; $i++) { if (isset($_POST[$i])){ $selected = 'a' . $i; $antall = 'antall' . strval($i); $enhet = 'enhet' . strval($i); echo "<tr>"; echo "<td>" . "$_POST[$selected]" . "</td>"; echo "<td>" . "$_POST[$antall]" . "</td>"; echo "<td>" . "$_POST[$enhet]" . "</td>"; echo "</tr>"; } } echo "<tr height=10></tr> <tr><td colspan=2>Velg dato for bestillingen:</td> <td colspan=1>"; $myCalendar = new tc_calendar("date5", true, false); $myCalendar->setIcon("calendar/images/iconCalendar.gif"); $myCalendar->setDate(date('d'), date('m'), date('Y')); $myCalendar->setPath("calendar/"); $myCalendar->setYearInterval(2000, 2015); $myCalendar->dateAllow('2008-05-13', '2015-03-01'); $myCalendar->setDateFormat('j F Y'); $myCalendar->setAlignment('left', 'bottom'); $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year'); $myCalendar->writeScript(); echo "<INPUT TYPE='hidden' NAME='date' VALUE='this.form.date5.value'>"; echo "</td></tr>"; echo "<tr height=10></tr><tr> <td colspan=3>Skrive din melding nedenfor:</td> </tr>"; echo "<tr> <td colspan=3><textarea name='melding' cols='50' rows='5' resize=none></textarea></td> </tr>"; echo "<tr> [b]<td><center><input type='button' value='Tilbake' onClick='history.go(-1)'></center></td>[/b] <td colspan=2><center><input type='submit' value='Bestil'></center></td> </tr>"; echo "</form>"; echo "</table>"; ?> </html> I made a file for updating data. I do get the id back from the view page, but not the variable. What do I do wrong? I'm puzzling a few days, but just don't see it. This my code: Code: [Select] <?php // init $msg = ''; $errorMsg = ''; $rep_id = array(); $componist = ''; $repertoire = ''; $titel = ''; $formOK= false; // + + + + + + + + GET + + + + + + + + if(isset($_GET['id'])) { $rep_id = inputControl($_GET['id']); } if(isset($_GET['componist'])) { $componist = inputControl($_GET['componist']); } //print "session: $login_id, $login_recht"; // TEST van de sessie // + + + + + + + + + + + + + + + + POST + + + + + + + + + + if (isset($_POST['UpdateRepSubmit'])) { if (isset($_POST['componist'])) { $componist = inputControl($_POST['componist']); } if (isset($_POST['titel'])) { $titel = inputControl($_POST['titel']); } } //print'<pre>'; print_r($repertoire); print '</pre>'; //TEST2 // + + + + + + + + + + + + + + + + + + + queries $select_query= "SELECT * FROM repertoire_eng ORDER BY componist ASC "; print $select_query; // TEST 3 // # # # # # # # # # # # database connectie # # # # # # # # # # $dblink = mysqli_connect($host,$user,$pass,$db) or die ('Mysql-connectie heeft gefaald.'); if (!$dblink) { // + + + + + + fout bij met maken van databaseverbinding $errorMsg = "Geen verbinding met de MySQL-server"; } else { $result = mysqli_query($dblink, $select_query); if($result) { $i = 0; while ($row = mysqli_fetch_array($result)) { // uitlezen resultaat $repertoire_ids[$i] = $row['id']; $componisten[$i] = $row['componist']; $titels[$i] = $row['titel']; $i++; } } else { // + + + + + fout bij het uitvoeren van de query $errorMsg = "De query kon niet worden uitgevoerd."; } // # # # # # # # # # # einde database connectie # # # # # # # # # mysqli_close($dblink); } ?> In the html block: Code: [Select] <div id="container"> <form action="edit_repertoire.php" method="post" name="edit_repertoire" onsubmit = "return checkForm(this)"> <fieldset> <legend>Update repertoire in your list:</legend> <!-- # # # # # # Toevoegen van een hiddenfield om de id op te halen uit de URL # # # # # # --> <input type="hidden" name="id" value = "<?php echo $rep_id; ?>" > <p>ID= <?php echo $rep_id; ?></p> <p> Componist = <?php echo $componisten; ?></p> <!-- + + + + + + + FORMREGELComponist + + + + + + + --> <div class="formregel"> <div class="formkolomlinks">Composer name:</div> <div class="formkolomrechts"><input name="componist" id="componist" type="text" maxlength="128" value="<?php echo $componist; ?>" /> Name first, then the initials! </div> </div><!-- Einde formregel --> <!-- ++ + + + + + FORMREGEL Compositie en of rol + + + + + + + --> <div class="formregel"> <div class="formkolomlinks">Composition and or role</div> <div class="formkolomrechts"><input name="titel" id="titel" type="text" maxlength="128" value="<?php echo $titel; ?>" /></div> </div><!-- Einde formregel --> <!-- +++++++ FORMREGEL +++++++ --> <div class="formregel"> <div class="formkolomlinks"><input name="updateRepSubmit" type="submit" value="Update repertoire" /></div> </div><!-- Einde formregel --> </fieldset> </form> <div class="clear"></div> </div><!-- einde container --> </div><!-- einde tot_wrap --> edit: added [code][/code] blocks Hello everyone! I am a new user and I have a simple question. How to download the database and create a backup. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=351259.0 |