PHP - Check Box To Go To Next Step ..help..
Similar Tutorialsi made a quick example of the problem im having. at step 5 i dont get the data for some reason. and its weird because when i resend the data it usually works by clicking refresh page. is very frustrating and makes no sense. please help Code: [Select] <?php if(!isset($_GET['step'])){ ?> <form method="post" action="form.php?step=2"> <input type="text" name="text" id="text"> <input type="submit"> </form> <?php } else if($_GET['step'] == 2){ ?> <form method="post" action="form.php?step=3"> <input type="hidden" name="text" id="text" value="<?php echo $_POST['text']; ?>"> <input type="text" name="text2" id="text2"> <input type="submit"> </form> <?php } else if($_GET['step'] == 3){ ?> <form method="post" action="form.php?step=4"> <input type="hidden" name="text" id="text" value="<?php echo $_POST['text']; ?>"> <input type="hidden" name="text2" id="text2" value="<?php echo $_POST['text2']; ?>"> <input type="text" name="text3" id="text3"> <input type="submit"> </form> <?php } else if($_GET['step'] == 4){ ?> <form method="post" action="form.php?step=5"> <input type="hidden" name="text" id="text" value="<?php echo $_POST['text']; ?>"> <input type="hidden" name="text2" id="text2" value="<?php echo $_POST['text2']; ?>"> <input type="hidden" name="text3" id="text3" value="<?php echo $_POST['text3']; ?>"> <input type="text" name="text4" id="text4"> <input type="submit"> </form> <?php } else if($_GET['step'] == 5){ echo $_POST['text']; echo $_POST['text2']; echo $_POST['text3']; echo $_POST['text4']; } ?> I'm trying to create an application where the admin is able to add mutiple goals. For example, - Goal 1 - Goal 2 - Goal 3 Once the goals have been set, he then can generate a task for users to follow the goals for a specific users.
For example USER A Goal 3, Goal 2, Goal 1
USER B Goal 2, Goal 1, Goal 3
USER C Goal 1, Goal 2, Goal 3
The user have to follow the goal as set and can only proceed to the next goal one the previous one has been completed. The goals will defer everyday. Anyone can guide me to the right direction?
Edited September 11, 2020 by ZulfadlyAshBurn Grammer I have just recently began learning PHP. I have a pretty solid foundation in general programming and PHP. As my first major PHP project I am trying to make myself an autobuyer for Fifa 15 using curt2008 Fifa API. He basically has everything there for me to use and I know that I have enough knowkledge to get a basic autobuyer going if I could just figure out how to log in. I have come to realize that the problem is that I have no idea what he is doing when he connects to the Fifa Web App. He has the code there for me, but I don't know what it is actually doing. I was hoping someone can point me to some documentation, a tutorial, or even exercises so that I may learn more about... logining into a web application? I don't even know what to call it.
Looking at connect.php he has a bunch of functions. Login, getSessionID, Phishing, getNucleusID, getShards, and all of them do a bunch a requests and use a bunch of headers. I don't know what this terminology is or how it all works together, but I would like to learn about it. Thats why I wanted to start learning PHP, for stuff like this. I just don't know where to look.
Thank You
Okay, I have moved on a few more steps and now starting to add, edit and delete records. The first issues I encountered before have been fixed as I read up on the prepare statement. I had to rewrite most of the code though. With this issue I am having trouble get the script to update or add new records. It produces no error messages: My DB: Column Type Null Default id int(11) No Autoincrement page varchar(255) Yes NULL title varchar(255) Yes NULL description varchar(255) Yes NULL keywords varchar(255) Yes NULL The code: view.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>View Records</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <h1>View Records</h1> <p><b>View All</b> | <a href="paginated.php">View Paginated</a></p> <?php // connect to the database include('connect.php'); // get the records from the database if ($result = $mysqli->query("SELECT * FROM URL ORDER BY id")) { // display records if there are records to display if ($result->num_rows > 0) { // display records in a table echo "<table border='1' cellpadding='10'>"; // set table headers echo " <tr> <th>ID</th> <th>Page</th> <th>Title</th> <th>Description</th> <th>Keywords</th> <th>Edit</th> <th>Delete</th></tr></tr>"; while ($row = $result->fetch_object()) { // set up a row for each record echo "<tr>"; echo "<td>" . $row->id . "</td>"; echo "<td>" . $row->page . "</td>"; echo "<td>" . $row->title . "</td>"; echo "<td>" . $row->description . "</td>"; echo "<td>" . $row->keywords . "</td>"; echo "<td><a href='records.php?id=" . $row->id . "'>Edit</a></td>"; echo "<td><a href='delete.php?id=" . $row->id . "'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; } // if there are no records in the database, display an alert message else { echo "No results to display!"; } } // show an error if there is an issue with the database query else { echo "Error: " . $mysqli->error; } // close database connection $mysqli->close(); ?> <a href="records.php">Add New Record</a> </body> </html> connect.php // connect to the database $mysqli = new mysqli($server, $user, $pass, $db); // show errors mysqli_report(MYSQLI_REPORT_ERROR); I have a DB It gets records from a sensor every 5 min This is then displayed on a Chart When I request 4 Hrs I get 48 records x 12 Sensors, Not a issue When I request 12 Hrs I get 144 records x 12 Sensors, A little Slower but Still OK But as I start to request longer periods Like 7 Days I start getting larger and Larger data sets causing time out issues with the AJAX Calls (4-30MB per sensor downloads of data) When looking at 4 weeks I really cant see the fine detail so is there a way to request records from MYSQL that drops some records in between Kinda like the Step function in a For loop If I request a period that has 2048 records but only want 204 records is there a way to say give me From -> To dates Step 10 and only return every 10th Record in the data set Thanks Hi all, I've been trying to create a page whereby a user enters a few details which is then emailed, but I'm seriously stuck on one issue. First page - console type Second page - serial number Only two steps at the moment as I need to figure it out. I'm passing everything into a variable from a post(ed) form. It appears on the next page fine, as I've been testing, but the details entered on the first page don't show on the third, however, the details from the second page do! Here is the code I have: Code: [Select] <?php switch ($step) { case "1": ?> <table width="75%" align="center"> <tr> <td colspan="2" valign="top"> <form action="?step=2" method="post" id="consoletype">Please select your console type<br /></td></tr> <tr><td align="center" valign="top" width="50%"> <label>Xbox 360 Original (Beige or Black)<br /><img src="images/xbox360orig.gif" width="250" height="250"><br /><input class="button" type="radio" name="console" value="xboxorig" /></label></td> <td align="center" valign="top" width="50%"><label>Xbox 360 Slim<br /><img src="images/xbox360slim.gif" width="250" height="250"><br /><input type="radio" name="console" value="xboxslim" /></label></td> </tr> <tr> <td colspan="2"> <input type="submit" value="Next"> </form> </td> </tr> </table> <?php echo $code; include("footer.php"); echo $code2; include("compat.php"); echo $code3; case "2": $console = $_POST['console']; echo $console; ?> Please enter your Xbox 360 Serial Number:<br /> <form action="?step=3" method="post"> <input name="serialno" type="text" size="20" maxlength="20"> <input type="submit" value="Next"> </form> <?php echo $code; include("footer.php"); echo $code2; include("compat.php"); echo $code3; case "3": echo "<br />"; $serialno = $_POST['serialno']; echo $serialno; echo $console; echo $code; include("footer.php"); echo $code2; include("compat.php"); echo $code3; } ?> I do understand it's messy at the moment but I don't see much point beautifying everything until I can solve this problem! Cheers! Hey guys, I have checked in google and on this forum for answers to my question but haven't found anything regarding validating each step of a multipage form, hence my post! I wonder if anyone can help me, or rather provide me with advice.... I am trying to create a multipage form, which so far i have done a basic one which i have done using my php cookbook by O'Reilly which is a very basic version, without any validations or anything.... My multipage has 3 steps: Step1: user details - takes users name, email etc Step 2: House details - Takes users address, house type, no of rooms, descriptions of rooms etc Step 3: Image upload - Allows user to upload 3 images max to display (using my original file upload script) As i said, my basic multipage form works, storing all posted values into sessions which can then be outputted at the end in a review page, which will be at the end of the form. In previous forms i have created, i always have an html form, which when posted or submitted, has an action of a separate php script which processes the form and validates it, sends email, updates database etc, and all errors are then stored in sessions and appear back on the form page until there are no errors displayed and then a success page is shown.... so the code i have taken from my cookbook doesn't seem to be able to allow me to validate EACH STEP of the form? it can validate at the end, when the user reviews and then the form is processed all in one go. But i want to be able to validate form entries at each step, rather than in one go. For example if a user leaves their 'town' field empty, an error message will be displayed before going to the next step... If you see the code i have done so fare below: Code: [Select] <?php //Figure out what stage to use if (($_SERVER['REQUEST_METHOD'] == 'GET') || (! isset($_POST['stage']))) { $stage = 1; } else { $stage = (int) $_POST['stage']; } //Save any submitted data if ($stage > 1) { foreach ($_POST as $key => $value) { $_SESSION[$key] = $value; } } if ($stage ==1) {?> <div id="submitCustomerForm"> <FORM ACTION='<?php echo $_SERVER['SCRIPT_NAME'] ?>' method='post'> <h7>Your details</h7> <br /> <div id="inputfield"> <label class="textleft" for="forename">forename:</label> <input class="fade" name="forename" type=text size="30" align="right" maxlength="15" id="forename" value="<?php echo $_SESSION['forename']?>"> </div> <div id="inputfield"> <label class="textleft" for="surname">surname:</label> <input class="fade" name="surname" type=text size="30" maxlength="15" id="surname" align="right" value="<?php echo $_SESSION['surname']?>"> </div> <div id="inputfield"> <label class="textleft" for="email">email:</label> <input class="fade" name="email" type=text size="30" maxlength="30" align="right" id="email" value="<?php echo $_SESSION['email']?>"> </div> <br /> <h7>Your property Address</h7> <br /> <div id="inputfield"> <label class="textleft" for="address1">Address Line 1:</label> <input class="fade" name="address1" type=text size="30" maxlength="30" id="address1" value="<?php echo $_SESSION['address1'];?>" /> </div> <div id="inputfield"> <label class="textleft" for="address2">Address Line 2:</label> <input class="fade" name="address2" type=text size="30" maxlength="30" id="address2" value="<?php echo $_SESSION['address2'];?>" /> </div> <div id="inputfield"> <label class="textleft" for="town">Town/City:</label> <input class="fade" name="town" type=text size="30" maxlength="30" id="town" value="<?php echo $_SESSION['town'];?>" /> </div> <div id="inputfield"> <label class="textleft" for="county">County:</label> <input class="fade" name="county" type=text size="30" maxlength="30" id="county" value="<?php echo $_SESSION['county'];?>" /> </div> <div id="inputfield"> <label class="textleft" for="postcode">Post Code:<span class="asterix">*</span></label> <input class="fade" name="postcode" type=text size="30" maxlength="30" id="postcode" value="<?php echo $_SESSION['postcode'];?>" /> </div> <input type='hidden' name='stage' value='<?php echo $stage + 1 ?>'/> <input name="Next" class="submit" type="image" align ="right" src="Images/updateButton.png" /> </FORM> </div> <?php } else if ($stage == 2) { ?> <div id="submitCustomerForm"> <FORM ENCTYPE="multipart/form-data" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <div id="divinputfile"> <input name="userfile" type="file" size="30" id="userfile" onchange="document.getElementById('fakeuserfile').value = this.value;"/> <div id="fakeinputfile"><input name="fakeuserfile" type="text" id="fakeuserfile" /></div> </div> <br /> <input type='hidden' name='stage' value='<?php echo $stage + 1 ?>'/> <input type="image" src="Images/upload.png" align="right" name="Send File" /> <br /> <br /> </FORM> </div> <?php } else if ($stage == 3) {?> <p class="largeblue"> hello there <?php echo $_SESSION['forename']; echo $_SESSION['surname'];?> <br /> the first line of your address is: <?php echo $_SESSION['address1'];?> <br /> the second line of your address is: <?php echo $_SESSION['address2'];?> </p> <?php } ?> For the 'form action' it uses Quote <?php echo $_SERVER['SCRIPT_NAME'] ?> meaning that the form reloads the page, upon which the stage number has changed and therefore loads next step. Where as normally, i have the path for my process script which would handle validation etc and then send them to a success screen or back to the form displaying errors. I propose a few ideas that i could do to get around this, which i just wanted to get a bit of insight on, as to which way of going about this is the right one!! My first idea would be to treat each step of the form as a separate form almost. Doing a form as i normally do, where the form is on one page, then the completed form is sent to a processing page, which processes the entries, sends user back to the form page with errors if there are any, or if it is all ok, increase the 'stage number' in a session and then use a header to go to next page(the next step of the form. at the top of each page is a check to whether the stage number is the same as the step number of the form. OR would i put all my validation in one page, with all the steps of the form as i have at the moment? OR is there a way to send each step of the form to a process script, which then sends the user back to the original form displaying errors if there are any or then moves them to the next step?? Just a little confused with which method to do this, i dont want to start working on it and find out i have done it completely the wrong way!! any help would be greatly received, thanks guys!! Craig I'm stuck at trying to figure out out to complete the 3 Step scripts to accomplish passing $variables between 2 different servers. Since there will actually be 12 Non-POST $variables involved in the SERVER #1 to SERVER #2 transfer , it doesn't appear that trying to put these all in a URL string and going the 'GET' route is practical.
I'm just using 3 short test variables in the examples. My eyeballs started rolling within I ran across something about 'CURL' that might be a necessary part of the solution?
The code I have been able to hammer out so far is below as STEP 1, STEP 2 and STEP 3.
STEP 1
<?php // submit.php // STEP 1 // On (LOCAL) SERVER #1 TO relay $variables to 'process.php' on (REMOTE) SERVER #2 // To submit $variables to directly another destination server script // NOTE: The $variable are NOT the result of Form Input !!! // For login Authenticaion ALL 3 must match db entries on SERVER #2 // NOTE: (Again) The $variables are NOT the result of Form Input !!! $userid = "adam"; $passwd = "eve"; $pscode = "peterpan"; // NOTE: (Again) The $variable are NOT the result of Form Input !!! // These $variables are needed for MySQL db INSERT on the destination URL server // For testing simplicity (actual data will be 12 $variables) $a = "apple"; $b = "banana"; $u = "1234567; // // Not sure if something called 'CURL' is needed here ??? // $submit_to_url = http://www.blahblah.com/process.php"; ?>STEP 2 <?php // processor.php // STEP 2 // ON SERVER #2 TO RECEIVE DATA DIRECTLY FROM SERVER #1 'submit.php' // To receive and process the $variables into a MySQL db on SERVER #2 // NOTE: The $variables are NOT the result of Form Input !!! // First validate $userid, $passwd & $pscode against `verify` table MySQL records require '/SERVER_2_securelocation_for_database_connection/secret_mysqli.php'; if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // // Not sure if something called 'CURL' is needed here ??? // // These login $variables are from submit.php on SERVER #1 $userid $passwd $pscode $sql="SELECT `userid`, `passwd`, `pscode` FROM `verify` WHERE `userid` = '$userid'" AND `passwd` = '$passwd` AND `pscode` = '$pscode'; $result = mysqli_query($con,$sql); if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } // // Then some Authentication code if ALL 3 components match // // If Authentication = true then $passed = "YES" must sent // be sent back to the 'finalstep.php' script on SERVER #1 // If Authentication (or connection) = false ... $passed = "NO" $return_to_url = http://www.blahblah.com/finalstep.php"; // These $variables are from submit.php on SERVER #1 $a = "apple"; $b = "banana"; $u = "1234567"; $sql="INSERT INTO `data` (`a`, `b`, `u`) VALUES ('$a', '$b', '$u')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } // If $SQL INSERT into `data` on SERVER #2 works ... // $status = "Pending" must be sent back to the 'finalstep.php' // script on SERVER #1 for MySQL db Table insertion // If $SQL INSERT into `data` = false, then $status = "Error" // NOTE: The '$u' $variable also needs send back to finalstep.php !!! $return_to_url = http://www.blahblah.com/finalstep.php"; mysqli_close($con); ?>STEP 3 <?php // finalstep.php // STEP 3 // ON SERVER #1 TO RECEIVE DATA DIRECTLY BACK FROM SERVER #2 process.php // To receive the $passed, $status and $u $variables for final step action // NOTE: The $variable are NOT the result of Form Input !!! require '/SERVER_1_securelocation_for_database_connection/secret_mysqli.php'; if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // These $variables are from process.php on SERVER #2 $passed $status $u $sql="UPDATE `tracking` SET `passed` = '$passed', `status` = '$status' WHERE `uniqueid` = '$u' "; $result = mysqli_query($con,$sql); if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } mysqli_close($con); ?>Thanks very much for any assistance and guidance. -freakingOUT I can add and delete data from my table. Now I need to be able to change one or more fields in an entry. So I want to retrieve a row from the db, display that data on a form where the user can change any field and then pass the changed data to an update.php program. I know how to go from form to php. But how do I pass the data from retrieve.php to a form so it will display? Do I use a URL and Get? Can I put the retrieve and form in the same program? ok so i can get this to work so i want to check if there is a video on inside my db if there is no video and nothing happens but if there is i want it to echo video Code: [Select] <?php if($video == ""){ }else{ echo "VIDEO"; } ?> Suppose i have a table with around 10 entries in which one column contains the id and the second column contains a checkbox... If a checkbox a selected and the button (below the table) is pressed then i want to delete the columns corresponding the checked checkboxes.... I am not getting how sgould i pass the get variable on the link of the button??? -Pranshu Agrawal pranshu.a.11@gmail.com Hello their, I'm wanting to use PHP to check to see if a username and password match a remote RDP server. The reason I ask is because I want to verify that the information the user is giving is correct. I'm looking though LDAP but I have no idea what I'm looking for. To recap, I would like to login to a RDP server and return a result based on if it completed. Thank-you for reading Paul P.S Sorry for the bad English, I seemed to forgot how to spell some words and have had to replace them with longer sentences Hello, I have created a little voting script for my site. The insertion code into the MySQL databse when they vote is very simple: $ipaddress = addslashes($_POST['ipaddress']); $theid = addslashes($_POST['theid']); $gamert = addslashes($_POST['gamert']); $serveron = addslashes($_POST['serveron']); $db = mysql_connect("localhost", "username", "password"); mysql_select_db("thedb",$db); mysql_query ("INSERT INTO voting (theid,ipaddress,gamert,serveron2) VALUES ('$theid','$ipaddress','$gamert','$serveron') "); Obviously I only want them to be able to vote once. What is the best way to do a check of the IPs already in the database and check against theirs before submitting? Thanks. I am unable to execute mysql_num_rows properly in this program. Code: [Select] <?php $link=mysql_connect("localhost","root",""); $db = mysql_select_db("myDB",$link); $result = mysql_query("SELECT * FROM jobs WHERE jobType=abc"); $num = mysql_num_rows($result); echo "Found $num records"; ?> error is mysql_num_rows() expects parameter 1 to be resource <?php // your email address $youremail = "twitchkuztomz@gmail.com"; // the subject of the email $msg = $_POST['notes']; $subject = $_POST['subject']; $email = $_POST['email']; $name = $_POST['name']; if(empty($youremail)) { die("No email address added. Please go back."); } elseif(empty($name)) { die("No name added. Please go back."); } elseif(empty($msg)) { die("No notes added. Please go back."); } else { if(mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n")) { echo "Email sent."; } else { echo "Mail() is not enabled."; } } $ch1 = $_POST['ch1']; $ch2 = $_POST['ch2']; $ch3 = $_POST['ch3']; $ch4 = $_POST['ch4']; $ch5 = $_POST['ch5']; ?> Thats the code i got so far i need it to mail the checked options with the messeges..... Thank you Hi, im new to php and got a simple query. i have built a web gallery and i want to add keywords to pictures, ive built the interface and mysql statements so it lists all possible keywords and creates a tick box for the user to use. ive created a table to join the image id's to my keyword id's as its going to be a many to many relationship, ive also built the sql statement below to select the highlighted image, but im not sure how i can join the looping of all keywords to generate the tick boxes and then to loop again to populate the tickboxes that are saved within the DB - if that makes sense?? SELECT * FROM images,img_key,keywords where img_key.img_id=images.id and keywords.id=img_key.key_id and images.id='2' Hi, I'd like to know what the most efficient code is for checking the first 2 digits of a string. eg a strings first 2 digits must equal '07' thanks, Hey, I'm trying to check if a username is unique, but for some reason none of the methods that I've looked up seem to work. I'm aiming for the code to check if a username is unique, and if get the user to input the name again. $get = "SELECT `i` FROM `m` WHERE `i`=\"$r\""; $checkResults = mysql_query($getRandomness); while(mysql_num_row($checkResults) > 0) { //some code... //check again $get = "SELECT `i` FROM `m` WHERE `i`=$r"; $checkResults = mysql_query($get); } The error comes from the while line, but it comes up during the first check because the record is empty. This is the error: "Fatal error: Call to undefined function mysql_num_row()" does anyone have code for checking to make sure an email address is typed in correct Hi guys, I am trying to get a admin panel, which when the user is logged in, it will check if there user access is(say for this post) 9... If there access is 9 in the database then direct to admin panel if not return them home. Thanks guys |