PHP - Multipage Forms - With Validation At Each Step!! Help!
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 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 have tried this for about 2 solid hours and I cannot figure out how to make multiple forms that have the same ID. Definition: I have 3 pages and they all have different information that needs to be placed into the database. I have no problem doing that the trouble comes when I try to make the 3 different database entry's have the same ID as the first form. My thought was to have the first form be completed then after the data was placed it would use mysql to pull the ID back out by using the WHERE clause to match the persons last name. Code: [Select] //Connection to the Mysql_Database $con = mysql_connect("####", "####", "####"); if(!$con){ die("There was an error connecting to your mysql_database" . mysql_error()); } //Variables to be entered into Patient_Data $last_name = $_POST['last_name']; //Intialize and Select the correct database. mysql_select_db("####"); //Format the data for entry into the mysql Database. $query = mysql_query("INSERT INTO Patient_Data VALUES ('', '$last_name)"); //Verify that the operation has worked if(!$query){ die("Lost in Transmission!" . mysql_error()); } $id_find = mysql_query("SELECT * FROM #### WHERE last_name='$last_name'"); while($id = mysql_fetch_row($id_find)){?> <!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 name="MedicalHistory" action="https://evansvillesurgical.com/med-record.php?id=<?php echo $id['id'];}?>" enctype="application/x-www-form-urlencoded" method="post"> Any help would be greatly appreciated. Even if it's just describing in Pseduo code a better way to go about this. Thanks, Colton Wagner Set up: * XAMPP 1.7.3 * Apache 2.2.14 (IPv6 enabled) + OpenSSL 0.9.8l * MySQL 5.1.41 + PBXT engine * PHP 5.3.1 * phpMyAdmin 3.2.4 * Perl 5.10.1 * FileZilla FTP Server 0.9.33 * Mercury Mail Transport System 4.72 I'm trying to set up a multipage registration script. It's tuff! I've set up some basic scripts to distribute variables into the correct tables from previous forms using a session. But I want the script to check the input from form one is valid before it moves on to form 2. Here are my scripts: form 1: <html> <head> <title>Register</title> <style type="text/css"> td { vertical-align: top; } </style> </head> <body> <form action="form2.php" method="post"> <table> <tr> <td><label for="name">Username:</label></td> <td><input type="text" name="name" id="name" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="password">Password:</label></td> <td><input type="password" name="password" id="password" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="first_name">First name:</label></td> <td><input type="text" name="first_name" id="first_name" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="last_name">Last name:</label></td> <td><input type="text" name="last_name" id="last_name" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="email">Email:</label></td> <td><input type="text" name="email" id="email" size="20" maxlength="50" value=""/></td> </tr><tr> <td><label for="address">Address:</label></td> <td><input type="text" name="address" id="address" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="city">City/Town:</label></td> <td><input type="text" name="city" id="city" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="county">County:</label></td> <td><input type="text" name="county" id="county" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="post">Postcode:</label></td> <td><input type="text" name="post" id="post" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="home">Home Number:</label></td> <td><input type="text" name="home" id="home" size="20" maxlength="20" value=""/></td> </tr><tr> <td><label for="mobile">Mobile:</label></td> <td><input type="text" name="mobile" id="mobile" size="20" maxlength="20" value=""/></td> </tr><tr> <td> </td> <td><input type="submit" name="submit" value="Sumbit"/></td> </tr> </table> </form> </body> </html> Form 2: <?php //let's start the session session_start(); //now, let's register our session variables session_register('name'); session_register('password'); session_register('first_name'); session_register('last_name'); session_register('email'); session_register('address'); session_register('city'); session_register('county'); session_register('post'); session_register('home'); session_register('mobile'); //finally, let's store our posted values in the session variables $_SESSION['name'] = $_POST['name']; $_SESSION['password'] = $_POST['password']; $_SESSION['first_name'] = $_POST['first_name']; $_SESSION['last_name'] = $_POST['last_name']; $_SESSION['email'] = $_POST['email']; $_SESSION['address'] = $_POST['address']; $_SESSION['city'] = $_POST['city']; $_SESSION['county'] = $_POST['county']; $_SESSION['post'] = $_POST['post']; $_SESSION['home'] = $_POST['home']; $_SESSION['mobile'] = $_POST['mobile']; ?> <html> <head> <title>Register</title> <style type="text/css"> td { vertical-align: top; } </style> </head> <body> <form action="form3.php" method="post"> <table> <tr> <td><label for="bio">Biography:</label></td> <td><input type="text" name="bio" id="bio" size="400" maxlength="500" value=""/></td> </tr><tr> <td> </td> <td><input type="submit" name="submit" value="Sumbit"/></td> </tr> </table> </form> </body> </html> I've also got form3.php and process_forms.php(that's where I mysql_real_escape_string and input the data) but that's probably not relevant. How would I get this to work? Are there any sites I should look at that you'd recommend? Any help appreciated. 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! 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? Hello, I just assembly a form and for styling it I am using CSS in an external file. Problem is that IE8 and I don't know about 7 (in IE9 is ok) it doesn't show the styling inside the form... My structure is something like this: (in any other situation my css styling is displayed normally) Code: [Select] <form> <span class="myclass"> </span> </form>Is there any fix for it? Thank you I need someone that is really good with php forms, looking for major help. I am attempting to create a login page, but my script is giving errors in relation to the forms. Involved PHP: Code: [Select] $username = mysql_real_escape_string($_POST['username']); if ($_POST['submit']=='Login') { $md5pass = md5($_POST['password']); $sql = "SELECT id,username FROM members WHERE username = '$username' AND password = '$md5pass'"; //etc etc... Involved HTML: Code: [Select] <form id="f6" action="" method="post" onsubmit="return weCheckForm(this)"> <fieldset id="e6" class="cc32"> <label id="e5" class="cc33" for="e4"> Username </label> <input id="e4" class="cc34" type="text" name="username" title="username" size="23"><br> <label id="e3" class="cc33" for="e2"> Password </label> <input id="e2" class="cc34" type="password" name="password" title="password" size="23"><br> <input id="e1" class="cc35" type="submit" title="submit" value="Login"> </fieldset> </form> Errors received: Notice: Undefined index: username in C:\(etc etc...) on line 4 Notice: Undefined index: submit in C:\(etc etc...) on line 6 Now I know that the problem is username and submit are undefined. However, I do not know how to define them in relation to the forms. We have this form that customers can make their own contact forms, and then it gets inserted to the database. We can show the forms with no problems, the problem lies when someone hits submit, how do I echo out the values of the form when I'm not sure what the input name or id is going to be? This sample form generated this code Code: [Select] <div class="element"> <label id="label-element-3" class="label" style="color:#4DBCE9;font-family:Trebuchet MS;font-size:1.2em;font-weight:normal;"> <span class="labelelementvalue">Email</span> <span class="required">*</span></label> <div class="errormessage" id="errormessage-element-3"></div> <div class="option-container"> <input class="af-inputtext af-email af-formvalue " type="text" name="element-3" id="element-3" value="" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:260px;border-style:solid; border-color:#dcdcdc;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border-width:1px;padding:5px;"></div> </div> <div class="element"> <label id="label-element-4" class="label" style="color:#4DBCE9;font-family:Trebuchet MS;font-size:1.2em;font-weight:normal;"> <span class="labelelementvalue">Textarea</span></label> <div class="errormessage" id="errormessage-element-4"></div> <div class="option-container"> <textarea class="af-textarea af-formvalue " name="element-4" id="element-4" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:300px;border-style:solid; border-color:#dcdcdc;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border-width:1px;padding:5px;" rows="6"></textarea></div> </div> <div class="element"> </div> If you notice, each input type is named "element-" with a number afterwards. So each input could be like "element-4", "element-21", and so forth. How would I post those values of the input fields when they are automatically named? Thanks in advance I am starting to build out a class to handle forms. I want to be able to add and edit data in some cases and just add data in other cases. Also want to do some ajax stuff to prevent from having to reload the pages in certain cases. I would like to view how some other form classes work so I can model mine to what I like about others but suit my needs. I was wondering if anyone has worked with any preexisting form classes that they could recommend. I know libraries like zend and so on have these built in and wasnt sure if anyone liked any one specifically and why. ok i have a questions i making a form so when users sign up to my website they we have an account page and in the account page the will have some more fields they need to filll in which i would use INSERT to put the things inside my db but what if they want to update there account should i use UPDATE i need a form that is hidden until the user clicks a button on a calendar only Then the form will be visible and have a field for the day that way pressed on submit the form would go back to being invisible.
not sure how to implement this can anyone help
Hi there, I'm new to php/MySQL. Just wondering how to create a multipage form with a back, save and submit button. Also, how do you stored the form data into the datebase and how do you display a list of submitted forms by the user to the user. Hi, im new to the forum and also to php, ive had a look through the tutorials and various threads but cant seem to find what im after. im created a simply image gallery that auto creates my thumbnails and allows for editing the image with gdlibrary etc all very good here. I recently decided to start work on the image keyword tagging so i could carry out searches etc on my very large image collection. i created the usual 3 table setup as im going to have a many to many relationship, so i have my "images" table, "keywords" table and a "img_key" table to link them together. As i understand it this would seem like the best setup for what i want to achieve, if not would someone be able to advise what i should be doing to get better results. Ok so the main problem i have now is that i want to show a series of check boxes underneath each image that gets selected so i can start tagging the uploaded images, to do this i used "select * from keywords" which gave me all keywords available - which is what i want...... However, i now want to somehow add to this so that once the page loads it knows which keywords have already been selected and ticks the relevant boxes automatically, as I have an sql update statement linked to the tickboxes/submit button i want to ensure i dont forget to re-tick any boxes So in a nutshell i need help with displaying all keywords each as a tickbox and if they have already been linked in my 'img_key' link table then they will tick the related tick box automatically , depending on what i need to change im guessing i may need to revise my updating of mysql ? ive been struggling with this silly problem now for a few weeks so im desperate for some assistance |