PHP - Passing $_post Data Into Insert Into Query
I've been poking around the Internet for the answer to this without any success. This query APPEARS to run, but NOTHING GETS INSERTED. The QuestionID in the Questions table is set to auto-increment, so I only need the QuestionText data for this table. the QuestionID in the Answers table is not because there might be four or five options per question. The snippets of code under consideration is pasted below
snipped from index.php: Code: [Select] <form action="./newquestion.php" method="post"> Question Text:<br><input type="text" size=100 name="QuestionText" /><br><br> <input type="submit" value="Enter next question"/> </form> Then snipped from newquestion.php mysql_select_db(quiz); $query = mysql_query("INSERT INTO Questions VALUES ('$_POST[QuestionText]'"); $result = mysql_query($query); Thank you all. I'm sure I'll learn this pretty fast, but I still need a little help. Similar Tutorialsi want the name of a picture stored in my db after i upload it the data is not stored in the db after i run this script, but i dont get errors either i print the two vars before sending them, and they get printed fine any help on this would be greatly appreciated thanks ! <?php error_reporting(E_ALL); ini_set("display_errors", 1); // INCLUDE THE CLASS FILE include('ImageLib.Class.php'); include("./includes/egl_inc.php"); $displayMessage = ''; if($_POST){ if(isset($_FILES['image_file'])){ // SEE THE MAGIC HAPPEN $destination_path = 'uploads/'; $post_file_name = 'image_file'; $width = 600; $height = 400; $scale = false; $trim = true; $uniqueName = true; $img = ImageLib::getInstance()->upload($post_file_name, $destination_path, $uniqueName)->resize($width, $height, $scale, $trim)->save(); $imgstr = mysql_real_escape_string ($img); $fileName = $_FILES['image_file']['name']; $displayMessage = '<div class="image"><img src="'.$destination_path.$fileName.'" /><br />Uploaded And Resized...With new file name : "'.$img.'"</div><br /><br />'; $playerid=$_SESSION['tid']; $matchdetails = mysql_fetch_array(mysql_query("SELECT id FROM ffa_matches WHERE status=2 and admin=$playerid")); $id = $matchdetails[id]; print $img;print $imgstr; print $id; mysql_query(" INSERT INTO ffa_screens (imgname,match) VALUES( '" . mysql_real_escape_string($imgstr) . "', '" . mysql_real_escape_string($id) . "' )"); }} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>ImageLib Samples By Rahul Kate</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style> body{font-family: arial; font-size:12px; color:#444444; padding:20px;} li{margin-top:10px;} .image{color:green;} .image img{margin-bottom:5px;} </style> </head> <body> <h1>ImageLib | Upload Image, move it to Uploads folder and Resize it and Trim</h1> <?php echo $displayMessage; ?> <form method="post" enctype="multipart/form-data"> Select Image<br /> <input type="file" name="image_file" id="image_file" /> <br /> <br /> <input type="submit" name="submit" value="Submit" /> <br /> <br /> <a href="index.html">Back TO Home</a> </form> </body> </html> I have tried several attempts and can get data to select and using echo display it, however, I need to take this data and insert it into the database in a separate table. I have the following which does hafl the job, can I get some pointers on the rest. I have looked everywhere and not found a solution, at all. // Selects the data I need <?php mysql_connect("PRIVATE INFO","PRIVATE INFO","PRIVATE INFO") or die("Could not connect: " . mysql_error()); mysql_select_db("wpdb"); $result = mysql_query("SELECT ID FROM wp_posts WHERE post_title LIKE '%future%' AND post_status = 'publish' OR post_title LIKE '%option%' AND post_content LIKE '%fundamental%' AND post_status = 'publish' ORDER BY post_date DESC"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['ID']; echo "<br />";}; ?> Thought maybe something like the following would work, but am at a loss: INSERT INTO wp_term_relationships (object_id, term_taxonomy_id, term_order) SELECT ID FROM wp_posts WHERE post_title LIKE '%future%' AND post_status = 'publish' OR post_title LIKE '%option%' AND post_content LIKE '%fundamental%' AND post_status = 'publish' ORDER BY post_date DESC while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) VALUES ($row['ID'], '25', '0') I have a some value that are being generated from a database then thrown into <li><href> to create a list that user can click and fetch data through ajax right now its in a form select/menu and works fine however I need to convert to a list and use and onKeyDown event Code: [Select] <form> <select name="users" size="<?php echo $num_rows;?>" onchange="showUser(this.value)" > <?php do { ?> <option value="<?php echo $row_Recordset1['item_id']?>"><?php echo $row_Recordset1['item_id'].' '. $row_Recordset1['item_name']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </select> </form> I need to correct this Code: [Select] <ol> <?php do { ?> <li onKeyDown="showUser(this.value)"><a href="getmenu.php?item_id="<?php echo $row_Recordset1['item_id']?>"> <?php echo $row_Recordset1['item_name']?></a></li> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </ol> This is what I have for code: Code: [Select] <?php $title="Login"; $metakeywords="login, email"; $metadescription="Login to Dating Snap!"; include('header.php'); $user = clean_up($_POST['email']); $pass = clean_up($_POST['password']); if($user && $pass) { $pass = md5($pass); //compare the encrypted password $sql="SELECT id,email,type,password,activation_key FROM `users` WHERE `email`='$user' AND `password`='$pass'"; $query=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) > 0) { $lllrow = mysql_fetch_assoc($query); if($lllrow['activation_key'] == 0){ $_SESSION['id'] = $lllrow['id']; $_SESSION['type'] = $lllrow['type']; $_SESSION['email'] = $lllrow['email']; $_SESSION['password'] = $lllrow['password']; $date=date("M d Y"); $time=date("g:i A"); $sql3 ="UPDATE `users` SET `last_ip`='{$_SERVER['REMOTE_ADDR']}', `last_login`='$date $time' WHERE `id`='".$_SESSION['id']."'"; $res3 = mysql_query($sql3) or die(mysql_error()); }else{ echo "<div class='error'>You need to activate your account first!</div>"; } echo '<meta http-equiv="REFRESH" content="0;url=index.php">'; } else { echo "<div class='error'>Email and password combination is incorrect!</div>"; } }else{ if(!$_GET['step'] && $_POST['newpassword']){ $email = clean_up($_POST['email']); $password = clean_up($_POST['newpassword']); $sql = "SELECT * FROM `users` WHERE `email`='$email'"; $query = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) > 0) { echo "That email is already being used, please try another."; }else{ $activation_number = rand( ); $subject = 'Activate your account on datingsnap.com'; $message = 'Dear '.$first.' '.$last.',<br>Thank you for registering for an account on Dating Snap. Please <a href="http://datingsnap.com/index.php?action=activate&id='.$activation_number.'">Click Here</a> to activate your new account.<br>All the best,<br> DatingSnap.com'; $headers = 'From: bobthewebbuilder@gmail.com' . "\r\n" . 'Content-Type: text/html; charset=\"iso-8859-1\"' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $sql = "INSERT into `users`(`activation_key`,`password`,`email`) VALUES ('$activation_number','".md5($password)."','$email');"; $query = mysql_query($sql) or die(mysql_error()); echo '<form method="post" action="index.php?action=login&step=1"><table width="100%"> <input id="email" type="hidden" name="email" value="$email"> <table width="100%"> <tr> <td class="content">*<b>First Name:</b></td> <td class="content"><input class="tarea" id="first" size="30" type="text" name="first"></td> </tr> <tr> <td class="content">*<b>Last Name:</b></td> <td class="content"><input class="tarea" id="last" size="30" type="text" name="last"></td> </tr> <tr><td width="150" class="content"></td><td class="content"><input type="submit" name="submit" value="Next step"></td></tr></form></table>'; } if($_GET['step'] == "1" && $_POST['email']){ $email = clean_up($_POST['email']); $first = clean_up($_POST['first']); $last = clean_up($_POST['last']); $sql = "UPDATE `users` SET `first`='$first',`last`='$last' WHERE `email`='$email'"; $query = mysql_query($sql) or die(mysql_error()); echo '<table width="100%"><form method="post" action="index.php?action=login&step=2"> <input id="email" type="hidden" name="email" value="$email"> <tr> <td class="content">*<b>Date of birth:</b><br><small>This will be used to calculate your age so be sure to use your correct birth date</small></td><td class="content"> <select name="month" id="month"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="day" id="day"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="year" id="year">'; $start_year = ($start_year) ? $start_year - 1 : date('Y') - 110; $end_year = ($end_year) ? $end_year : date('Y'); for ($i = $end_year; $i > $start_year; $i -= 1) { echo '<option value="'.$i.'">'.$i.'</option>'; } echo '</select> </td> </tr><tr><td width="150" class="content"></td><td class="content"><input type="submit" name="submit" value="Next step"></td></tr></form></table>'; } if($_GET['step'] == "2" && $_POST['email']){ $email = clean_up($_POST['email']); $month=clean_up($_POST['month']); $day=clean_up($_POST['day']); $year=clean_up($_POST['year']); $sql = "UPDATE `users` SET `bdate`='$year-$month-$day' WHERE `email`='$email'"; $query = mysql_query($sql) or die(mysql_error()); echo "Done step two!"; } } //end if email } include('footer.php'); ?> How come $_POST['email'] isn't getting passed down the steps? I have a hidden field that holds it in each step... what am I overlooking? I'm practicing my OOP skills and want to pass $_POST values to an Object's Instance Variables when a form is submitted. This is what I have so far... index.php Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> </head> <body> <!-- Registration Form --> <form method="post" action="results.php"> <!-- Registration Fields --> <div> <label for="email">E-mail:</label> <input type="text" name="email" class="txt" id="email" /> </div> <div> <label for="password">Password:</label> <input type="password" name="password" class="txt" id="password" /> </div> <div> <input type="submit" name="btnSubmit" value="Register" class="btn" id="btnSubmit" /> </div> </form> </body> </html> results.php Code: [Select] <?php include ('classes/FormHandler.class.php'); ?> FormHandler.class.php Code: [Select] <?php class HandleForm { // Define Variables. private $email; private $password; public function __construct($email, $password){ $this->email = $email; $this->password = $password; } } ?> I'm a little stuck on how I initialize the Instance Variables in the Constructor?! TomTees ok so here the deal. i have to write a script that searches a giant database of school and returns the contact info for all schools matching the search term. no big deal it's cake to code something that simple... but wait there more! the search must be executed by a joomla page... we crap. joomla doesn't allow me to run php scripts... so i found a little plugin called jumi that lets me do just that. and it works great minus all the errors joomla spits out because the mysql_connect statement and the mysql_query statment are connecting to a different database than the one joomla is installed onand thus joomla thinks the tables i am searching don't exist so joomla outputs this 4 page long error code in a bright red box a the top of the page. so i tried turning off joomls error reporting.. no bueno. so i figured no problemo i'll just have the script call out to a .php file hosted else where on the server and pass the search terms to that file via $_POST. then have said file execute a quick search of the database and return the results back to the original joomla page from whence the search commenced via a nice tidy $_POST array. one problem how in hades do you pass around php arrays via $_POST? Dear All Members here is my table data.. (4 Columns/1row in mysql table)
id order_no order_date miles How to split(miles) single column into (state, miles) two columns and output like following 5 columns /4rows in mysql using php code.
(5 Columns in mysql table) id order_no order_date state miles 310 001 02-15-2020 MI 108.53 310 001 02-15-2020 Oh 194.57 310 001 02-15-2020 PA 182.22
310 001 02-15-2020 WA 238.57 ------------------my php code -----------
<?php
if(isset($_POST["add"]))
$miles = explode("\r\n", $_POST["miles"]);
$query = $dbh->prepare($sql);
$lastInsertId = $dbh->lastInsertId(); if($query->execute()) {
$sql = "update tis_invoice set flag='1' where order_no=:order_no"; $query->execute();
} ----------------- my form code ------------------
<?php -- Can any one help how to correct my code..present nothing inserted on table
Thank You Edited February 8, 2020 by karthicbabuHi, I need to pass value of variable to another php file. I thought it is possible to do it as following: <form action="products.php"> <INPUT TYPE=hidden NAME='id' . VALUE='$id'> </form> But the problem is like that. The php file inside which I want to write above html code has not using <form> tag and it has no buttons. So how to initiate the transfer of variable into another php file? Is the above idea is not the good idea? Are there any another ways? If you also have any feedback on my code, please do tell me. I wish to improve my coding base. Basically when you fill out the register form, it will check for data, then execute the insert query. But for some reason, the query will NOT insert into the database. In the following code below, I left out the field ID. Doesn't work with it anyways, and I'm not sure it makes a difference. Code: Code: [Select] mysql_query("INSERT INTO servers (username, password, name, type, description, ip, votes, beta) VALUES ($username, $password, $name, $server_type, $description, $ip, 0, 1)"); Full code: Code: [Select] <?php include_once("includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><? $title; ?></title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="header"> <h1><? $title; ?></h1> <h2><? $description; ?></h2> </div> <? include_once("includes/navigation.php"); ?> <div id="content"> <div id="right"> <h2>Create</h2> <div id="artlicles"> <?php if(!$_SESSION['user']) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $name = mysql_real_escape_string($_POST['name']); $server_type = mysql_real_escape_string($_POST['type']); $description = mysql_real_escape_string($_POST['description']); if(!$username || !$password || !$server_type || !$description || !$name) { echo "Note: Descriptions allow HTML. Any abuse of this will result in an IP and account ban. No warnings!<br/>All forms are required to be filled out.<br><form action='create.php' method='POST'><table><tr><td>Username</td><td><input type='text' name='username'></td></tr><tr><td>Password</td><td><input type='password' name='password'></td></tr>"; echo "<tr><td>Sever Name</td><td><input type='text' name='name' maxlength='35'></td></tr><tr><td>Type of Server</td><td><select name='type'> <option value='Any'>Any</option> <option value='PvP'>PvP</option> <option value='Creative'>Creative</option> <option value='Survival'>Survival</option> <option value='Roleplay'>RolePlay</option> </select></td></tr> <tr><td>Description</td><td><textarea maxlength='1500' rows='18' cols='40' name='description'></textarea></td></tr>"; echo "<tr><td>Submit</td><td><input type='submit'></td></tr></table></form>"; } elseif(strlen($password) < 8) { echo "Password needs to be higher than 8 characters!"; } elseif(strlen($username) > 13) { echo "Username can't be greater than 13 characters!"; } else { $check1 = mysql_query("SELECT username,name FROM servers WHERE username = '$username' OR name = '$name' LIMIT 1"); if(mysql_num_rows($check1) < 0) { echo "Sorry, there is already an account with this username and/or server name!"; } else { $ip = $_SERVER['REMOTE_ADDR']; mysql_query("INSERT INTO servers (username, password, name, type, description, ip, votes, beta) VALUES ($username, $password, $name, $server_type, $description, $ip, 0, 1)"); echo "Server has been succesfully created!"; } } } else { echo "You are currently logged in!"; } ?> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <a href="http://www.templatesold.com/" target="_blank">Website Templates</a> by <a href="http://www.free-css-templates.com/" target="_blank">Free CSS Templates</a> - Site Copyright MCTop </div> </div> </body> </html> Hi all, I'm looking for some pointers in regards to my form.. How would I firstly trim the $_POST value of the variables that come through via the form (I'm only using one for now)..I know I'm making a right dogs dinner of it. In my head I'm thinking, trim all the posts first before i even assign a variable to it ( i dont know if thats possible), then use an array for when more values start coming through via the form. You know as i make a contact form that requires more data from the user..
<?php require_once '../connection/dbconfig.php'; include_once('../connection/connectionz.php'); //get the values //Get the request method from the $_SERVER $requestType = $_SERVER['REQUEST_METHOD']; //this is what type //echo $requestType ; if($requestType == 'POST') { //now trim all $_POSTS $search_products = trim($_POST['search_products']); // if(empty($search_products)){ echo '<h4>You must type a word to search!</h4>'; }else{ $make = '<h4>No match found!</h4>'; $new_search_products = "%" . $search_products . "%"; $sql = "SELECT * FROM product WHERE name LIKE ?"; //prepared statement $stmt = mysqli_stmt_init($conDB); //prepare prepared statements if(!mysqli_stmt_prepare($stmt,$sql)) { echo "SQL Statement failed"; }else{ //bind parameters to the placeholder mysqli_stmt_bind_param($stmt, "s", $new_search_products ); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); echo'<h2> Search Result</h2>'; echo 'You searched for <strong><em>'. $search_products.'</em></strong>'; while($row = mysqli_fetch_assoc($result)){ echo '<h4> (ID : '.$row['pid']; echo ') Book Title : '.$row['name']; echo '</h4>'; } } } } ;?>
If any one can shed some light on this, or some pointers..that would be very nice... Thanks Darren
I have a web page that uses $_POST to pass the ID from web page to web page as they fill out forms using$ID=$_POST['id']The last page of the form passes this and other information to a php page that inserts the information that was passed into a database I have set up and then redirects back to the first page of the form. This is what I have so far. <?php // Change to the URL you want to redirect to $URL="Start.php"; header ("Location: $URL"); $ID=$_POST['id']; ?> What I want to happen however is when it redirects, I want it to pass the ID information back to the main page again as well. Can anyone help me out? 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? I recently had a customer say that one of my forms isn't working. For some reason the ID number is getting lost when she submits the form. The form code looks like: ... print "<form method='post' name='form' action='update.php'>"; ... print "<input type='hidden' name='id' value=\"$id\" />"; print "<input type='submit' name='submit' value=\"Save Session\" />"; print "</form>"; ... And the PHP code that gets executed looks like: ... //GET SESSION ID if(isset($_GET['id'])) { //ID from HTML link, before updates have been made $id = $_GET['id']; } elseif(isset($_POST['id'])) { //ID from form, after updates have been made $id = $_POST['id']; } else { $id = ''; } //IF SESSION ID IS VALID if(preg_match("/^\d+$/", $id)) { ... //ELSE, INVALID ID } else { $msg = "<span class='errorText'>Session ID not found or invalid.</span>"; } ... For some reason she usually gets the "Session ID not found..." error when submitting the form. Do you see any problems with the above code? Note that she has been able to sucessfully use the form before (in the same day); we have nearly 1,800 records submitted using these forms; and I am unable to duplicate the issue. So I'm at a loss on what to do next. Also, she talked with her IT person about the form. The IT person was able to submit data on his computer. So he reset her Internet options which seemed to fix the problem on her end temporarily. Note that she is using IE 7. She also said that she doesn't have access to any other browsers. I'm tempted to chalk this up as a personal computer issue, but wanted to get your input first. Hi, I am a curious fellow just beginning to use PHP. I understand the basics of what the $_GET and $_POST superglobals do, and how we can use them to retrieve data after form submission. I also know that since $_GET and $_POST are just associate arrays, we can create our own values in both $_GET and $_POST by writing statements like $_POST['variable'] = "value". I am wondering if it is at all possible to send data beyond form data by adding new key/value pairs into $_GET and $_POST. So for example, if I had a form that transferred username/password through Post, would it be possible for me to include further data by just saying $_POST['formtype'] = "house_insurance_form"? Basically what I'm getting at is trying to physically add your own data to $_POST or $_GET that you could pull from the next page where the form redirects to. In other words, can I send data beyond form data using these superglobals? I know I can do this with $_SESSION, but could I do it through $_POST or $_GET? I haven't been able to accomplish this, and I was just wondering if someone could give me an in-depth explanation of how this might work or how this is not possible. I would really really really appreciate it. Best Regards, -Sky I usually hate to post something like this as a first post...I'd like to at least do an into but I"m stumped and I think it's a totally stupid thing I"m not noticing. Anyway, this is the final step in a three step user verification; this is for a staff user to be verified. Anyway, by now they have already verified their email and entered a random code so I"m only worried about actually setting them to verified status in my database so they can start working on blogs etc. Anyway, this form is supposed to find all unverified staff members, and allow an admin to easily just click down the list (one at a time currently) and verify the user (ie. setting their database status to verified_staffUser). The username that is supposed to be verified (or declined and therefore their entry deleted) is supposed to be passed through as $_POST[vnsupUsername]. This is set each time it loops through and prints a new user. The problem is that it's only sending the final username when I click verify/decline on any user :\. I"m not sure why it's doing this. In firebug on firefox it's showing that the user name is set for each one to be properly in the form...but when I click on it (I am having on my machine) the username being worked with echoed..and it's always the last one that was entered into the database. I have no idea why this is happening ..any thoughts? Code: [Select] <?php if(isset($_GET[vnsufac]) || isset($_POST[svnsu]) || isset($_POST[dvnsu])){ // simply prints the back home button echo "<form action=\"http://localhost/~atharp1122/OGirly_Site/ogirly_staff_homepage.php\" method=\"post\">" ."<input type=\"submit\" value=\"Back to Staff Homepage\" style=\"margin-top:10px;\">"; // this will print out the form to verify/deny all new staff user requests that have been email verified $programCheckUVStaff = mysql_query("SELECT username, email, firstname, lastname FROM staffUNAP where verified_staff = '0'"); while($UVStaff = mysql_fetch_assoc($programCheckUVStaff)){ print "<div class=\"newVerifyUserContain\" >"; print "<div class=\"newVerifyUser\" >"; echo "<h3 style=\"text-align: center;\">Would you like to verify this Staff request?</h3>"; echo "<table><tr><td>" ."<img src=\"images/default_icons/di_bunny_rabbit.png\" width=\"56\" height=\"59\" />" ."<ul style=\"padding-left: 100px; padding-bottom: 20px; margin-top: -42px; list-style-type: none;\"><li>" ."{$UVStaff[username]} aka {$UVStaff[firstname]} {$UVStaff[lastname]}</li><li>" ."{$UVStaff[email]}</li></ul></td></tr><tr><td>" ."<form action=\"{$_SERVER[PHP_SELF]}\" method=\"post\">" ."<input type=\"checkbox\" name=\"isadmin\" value=\"1\" style=\"margin-left: 10px;\">Is Admin?" ."<input type=\"hidden\" name=\"vnsupUsername\" value=\"{$UVStaff['username']}\">" ."<input type=\"submit\" name=\"svnsu\" value=\"Verify Staff\" style=\"margin-left: 200px;\">" ."<input type=\"submit\" name=\"dvnsu\" value=\"Decline Request\">"; print "</table>"; print "</div></div>"; } } // verify a staff member if(isset($_POST[svnsu])){ echo "verifying a new user"; echo $_POST[vnsupUsername]; } ?> Hi Team, I have a php page where I have taken the same userid and linked in the next page and also used show/hide function. I am able to see that the userid is linking but when i submit the data is not getting insert and also no error Please help below is the Tower.php file. Code: [Select] <!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=iso-8859-1" /> <title>BHP2</title> <style type="text/css"> <!-- #Layer1 { position:absolute; width:1005px; height:578px; z-index:1; left: 157px; top: 1px; background-color: #993399; } #Layer2 { position:absolute; width:939px; height:114px; z-index:1; left: 35px; top: 35px; } #Layer3 { position:absolute; width:451px; height:169px; z-index:2; left: 270px; top: 296px; } #Layer4 { position:absolute; width:608px; height:68px; z-index:2; left: 273px; top: 10px; } #Layer5 { position:absolute; left:82px; top:188px; width:973px; height:52px; z-index:2; } #Layer6 { position:absolute; width:243px; height:106px; z-index:2; left: 68px; top: 43px; } .style1 { font-size: xx-large; font-style: italic; } .style2 {font-size: 52px} #Layer7 { position:absolute; width:824px; height:271px; z-index:2; left: 44px; top: 237px; } .style4 { font-size: xx-large; font-style: italic; font-weight: bold; color: #FF9933; } #Layer8 { position:absolute; width:800px; height:139px; z-index:2; left: 31px; top: 67px; } #Layer9 { position:absolute; width:610px; height:30px; z-index:2; left: 34px; top: 70px; } #Layer10 { position:absolute; width:611px; height:25px; z-index:2; left: 33px; top: 110px; } #Layer11 { position:absolute; width:614px; height:30px; z-index:2; left: 33px; top: 152px; } #Layer12 { position:absolute; width:615px; height:29px; z-index:2; left: 32px; top: 193px; } #Layer13 { position:absolute; width:187px; height:35px; z-index:2; left: 318px; top: 239px; } --> </style> </head> <body> <div id="Layer1"> <form id="form5" name="form5" method="link" action="Insert.php"> <div id="Layer2"> <div id="Layer6"><img src="AZimages/BHP-Billiton-logo.jpg" width="235" height="65" alt="BHP" /></div> <h1 align="center"> </h1> <div class="style1" id="Layer4"> <h1 align="center" class="style2">BHP DATA TRACKER </h1> </div> </div> <div id="Layer7"> <div align="center"><span class="style4">SELECT THE TOWER BELOW </span> <div id="Layer13"> <input type="hidden" name="empid" value="<?php echo $_GET['id']; ?>" size="20"> <input type="hidden" name="date" value="<?php echo date("Y-m-d H:i:s"); ?>" > <input type="submit" name="B1" value="Start !" /> </div> <div id="Layer12"> <div align="left"> <input name="rad1" type="radio" value="RF" id="rad1" /> <label >RF</label> </div> </div> <div id="Layer11"> <div align="left"> <input name="rad1" type="radio" value="ISAP" id="rad1" /> <label >ISAP</label> </div> </div> <div id="Layer10"> <div align="left"> <input name="rad1" type="radio" value="GSD" id="rad1" checked="checked" /> <label >GSD</label> </div> </div> <div id="Layer9"> <div align="left"> <input name="rad1" type="radio" id="rad1" value="CSD" /> <label>CSD</label> </p> </div> </div> <br /> </div> </div> </form> </div> </body> </html> Below is the insert.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"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BHP DATA SUMBIT</title> <?php include ("count.php"); ?> <?php if(isset($_GET['action'])) { $action = $_GET['action']; if ($action = 'yes') { include ("Connection.php"); $PName = $_POST['rad11']; $Date = date("Y-m-d H:i:s"); $empidno = $_POST['idd']; $qsdate = $_POST['testinput']; $cb1 = $_POST['chkbox1']; $cb2 = $_POST['chkbox2']; $cb3 = $_POST['chkbox3']; $cb4 = $_POST['chkbox4']; $cb5 = $_POST['chkbox5']; $Com = $_POST['textfield2']; $dd1 = $_POST['textfield']; $dd2 = $_POST['select']; $dd3 = $_POST['select2']; $dd4 = $_POST['textfield4']; $dd5 = $_POST['textfield3']; $dd6 = $_POST['select3']; $sev = $_POST['radio1']; $olddate = $_POST['odate']; $pname = $_POST['radiobutton']; $query="INSERT INTO bhp ticketinformation (`userid`, `processname`, `begindate`, `dateposted`, `CALL`, `EMAIL`, `NEW`, `EXISTING`, `Piroty`, `MTICKET`, `Services`, `group1`, `group2`, `Icall`, `Tcreatedtime`, `comment`) VALUES ( '$empidno' , '$pname' , '$olddate' , '$Date' , '$cb1' , '$cb2' , '$cb3' , '$cb4' , '$sev' , '$dd1' , '$dd2' , '$dd3' , '$dd4' , '$dd5' , '$dd6' , '$Com')"; mysql_query($query); Header('location:tower.php?id=' . $empidno); } } ?> <head> <style type="text/css"> <!-- #Layer1 { position:absolute; width:1023px; height:592px; z-index:1; left: 167px; top: 2px; background-color: #993399; } #Layer2 { position:absolute; width:939px; height:114px; z-index:1; left: 59px; top: 3px; } #Layer3 { position:absolute; width:451px; height:169px; z-index:2; left: 270px; top: 296px; } #Layer4 { position:absolute; width:608px; height:68px; z-index:2; left: 273px; top: 10px; } #Layer5 { position:absolute; left:82px; top:188px; width:973px; height:52px; z-index:2; } #Layer6 { position:absolute; width:238px; height:69px; z-index:2; left: 68px; top: 43px; } .style1 { font-size: xx-large; font-style: italic; } .style2 {font-size: 52px} #Layer7 { position:absolute; width:979px; height:209px; z-index:2; left: 32px; top: 181px; } #Layer8 { position:absolute; width:194px; height:36px; z-index:1; left: 25px; top: 15px; } #Layer9 { position:absolute; width:178px; height:37px; z-index:2; left: 249px; top: 13px; } #Layer10 { position:absolute; width:193px; height:34px; z-index:3; left: 443px; top: 13px; } #Layer11 { position:absolute; width:204px; height:32px; z-index:4; left: 670px; top: 15px; } #Layer12 { position:absolute; width:195px; height:40px; z-index:5; left: 28px; top: 73px; } #Layer13 { position:absolute; width:182px; height:38px; z-index:6; left: 250px; top: 76px; } #Layer14 { position:absolute; width:197px; height:36px; z-index:7; left: 446px; top: 77px; } #Layer15 { position:absolute; width:214px; height:35px; z-index:8; left: 670px; top: 77px; } #Layer16 { position:absolute; width:315px; height:45px; z-index:9; left: 16px; top: 144px; } #Layer17 { position:absolute; width:343px; height:43px; z-index:10; left: 339px; top: 145px; } #Layer18 { position:absolute; width:258px; height:48px; z-index:11; left: 708px; top: 146px; } #Layer19 { position:absolute; width:321px; height:60px; z-index:3; left: 59px; top: 419px; } #Layer20 { position:absolute; width:197px; height:41px; z-index:1; left: 27px; top: 6px; } #Layer21 { position:absolute; width:193px; height:36px; z-index:2; left: 249px; top: 7px; } #Layer22 { position:absolute; width:207px; height:38px; z-index:3; left: 453px; top: 7px; } #Layer23 { position:absolute; width:237px; height:36px; z-index:4; left: 677px; top: 9px; } #Layer24 { position:absolute; width:245px; height:45px; z-index:5; left: 399px; top: 2px; } #Layer25 { position:absolute; width:99px; height:31px; z-index:6; left: 288px; top: 121px; } #Layer26 { position:absolute; width:87px; height:29px; z-index:7; left: 439px; top: 123px; } --> </style> <script language="JavaScript" > function showInfo() { var elem = document.getElementById('verify'); if(document.testform.select3.value == "verify" || document.testform.select3.value == "verify1" ) { elem.style.display="inline"; } else { elem.style.display="none"; } } </script> <script language="JavaScript"> function validator() { if(document.testform.Checkbox1.checked == false && document.testform.Checkbox2.checked == false && document.testform.Checkbox3.checked == false && document.testform.Checkbox4.checked == false) { alert ('You did not choose any of the checkboxes!'); return false; } if (document.testform.textfield.value =="") { alert("Enter Max Ticket No"); return false; } if (document.testform.select.value == "" || document.testform.select.value == "SELECT SERVICE DROP DOWN") { alert ('Select the SELECT SERVICE DROP DOWN'); return false; } if (document.testform.select2.value == "" || document.testform.select2.value == "SELECT RG GROUP") { alert ('SELECT RG GROUP'); return false; } if (document.testform.select3.value == "" || document.testform.select3.value == "SELECT GROUPS") { alert ('SELECT GROUPS'); return false; } if (document.testform.textfield2.value =="") { alert("Comments Feild is Empty.If there are no Comment then type NA(Not Applicable)"); return false; } if (document.testform.Checkbox1.checked == false) document.getElementById("chkbox1").value = ""; else document.getElementById("chkbox1").value = "EMAIL"; if (document.testform.Checkbox2.checked == false) document.getElementById("chkbox2").value = ""; else document.getElementById("chkbox2").value = "NEW"; if (document.testform.Checkbox3.checked == false) document.getElementById("chkbox3").value = ""; else document.getElementById("chkbox3").value = "EXISTING"; if (document.testform.Checkbox4.checked == false) document.getElementById("chkbox4").value = ""; else document.getElementById("chkbox4").value = "CALL"; alert('Record has been posted in the portal'); } </script> </head> <body> <div id="Layer1"> <div id="Layer2"> <div id="Layer6"><img src="AZimages/BHP-Billiton-logo.jpg" width="235" height="67" alt="BHP" /></div> <h1 align="center"> </h1> <div class="style1" id="Layer4"> <h1 align="center" class="style2">BHP DATA TRACKER </h1> </div> </div> <div id="Layer7"> <form method="POST" action="Insert.php?action=yes&&id=<?php echo $_GET['empid']; ?>" name="testform" onSubmit="return validator();"> <div id="Layer8"> <input type="checkbox" id="Checkbox4" name="checkbox4" value="CALL" /> CALL</label> </div> <div id="Layer9"> <label> <input type="checkbox" id="Checkbox1" name="checkbox1" value="EMAIL" /> EMAIL</label> </div> <div id="Layer10"> <label> <input type="checkbox" id="Checkbox2" name="checkbox2" value="NEW" /> NEW</label> </div> <div id="Layer11"> <label> <input type="checkbox" id="Checkbox3" name="checkbox3" value="EXISTING" /> EXISTING</label> </div> <div id="Layer12"> <label> <input name="radio1" type="radio" id="radio1" value="P1" checked="checked" /> P1</label> </div> <div id="Layer13"> <label> <input name="radio1" type="radio" id="radio1" value="P2" /> P2</label> </div> <div id="Layer14"> <label> <input name="radio1" type="radio" id="radio1" value="P3" /> P3</label> </div> <div id="Layer15"> <label> <input name="radio1" type="radio" id="radio1" value="P4" /> P4</label> </div> <div id="Layer16"> <label>MAXIMUM TICKET <input type="text" name="textfield" /> </label> </div> <div id="Layer17"> <label>SERVICE DROP DOWN <select name="select" style="width: 162px; height: 23px"> <option>SELECT SERVICE DROP DOWN</option> <option>OTHER(FW)</option> <option>1 MESSAGE</option> <option>1 MOBILITY</option> <option>1 VOICE</option> <option>1 SAP</option> <option>1 PORTAL</option> <option>1 COLLAB</option> <option>1 GSAP</option> <option>1 SECURITY</option> <option>1 WAN</option> <option>S DOMAIN</option> <option>1 AUTH</option> <option>1 DOCM</option> <option>1 REMOTE</option> </select> </label> </div> <div id="Layer18"> <label>RG GROUP <select name="select2" style="width: 162px; height: 23px"> <option>SELECT RG GROUP</option> <option>I-AM-AU-AM-HWT</option> <option>I-EUS-IN-CSC-DSK-CSD</option> <option>I-EUS-IN-CSC-DSK-GSD</option> <option>I-EUS-GB-DCS-BHPVICFW</option> <option>I-ITS-AU-HW</option> <option>I-SRM-AU-IAM-LAMU</option> <option>I-ITS-AU-SW</option> <option>C-BHP-AU-CSC-LSD-NONBRG</option> <option>C-BHP-AU-ACN-AQM</option> </select> </label> </div> </div> <div id="Layer19"> <label>SELECT GROUPS <select name="select3" onchange="showInfo()" style="width: 162px; height: 23px"> <option value="none" >SELECT GROUPS</option> <option value="verify">TP</option> <option value="verify1">OA</option> <option>OC</option> <option>OTHERS</option> </select> </label> <div id="verify" style="display:none;"> <br/><br/> <label>INCOMING CALL/EMAIL TIME <input type="text" name="textfield4" /> </label> <br/><br/> <label>MAXIMO TICKET CREATED TIME <input type="text" name="textfield3" /> </label> </div> <div id="Layer24"> <label>COMMENTS <input type="text" name="textfield2" /> </label> </div> <div id="Layer26"> <input name="Reset" type="reset" id="Reset" value="Reset" /> </div> <div id="Layer25"> <input type="submit" name="Submit" value="Submit" /> <input type="hidden" name="chkbox1" id="chkbox1" /> <input type="hidden" name="chkbox2" id="chkbox2" /> <input type="hidden" name="chkbox3" id="chkbox3" /> <input type="hidden" name="chkbox4" id="chkbox4" /> <input type="hidden" name="chkbox5" id="chkbox5" /> <input type="hidden" name="rad11" id="rad11" value="<?php echo $_GET['rad1']; ?>" /> <input type="hidden" name="idd" id="idd" value="<?php echo $_GET['empid']; ?>" /> <input type="hidden" name="odate" id="odate" value="<?php echo $_GET['date']; ?>" /> </form> </div> </div> </div> </body> </html> THANKS IN ADVANCED Hi.. Sorry, if I need to repost my problem in while loop. cause until now I can't resolve my problem in saving all data from while loop. I have this code StockRequisition.php where FORM was displayed. <?php error_reporting(0); date_default_timezone_set("Asia/Singapore"); //set the time zone $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); $sr_date =date('Y-m-d H:i:s'); $sql = "SELECT sr_number FROM stock_requisition ORDER BY sr_date DESC LIMIT 1"; $result = mysql_query($sql, $con); if (!$result) { echo 'failed'; die(); } $total = mysql_num_rows($result); if ($total <= 0) { $currentSRNum = 1; $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } else { //------------------------------------------------------------------------------------------------------------------ // Stock Number iteration.... $row = mysql_fetch_assoc($result); $currentSRNum = (int)(substr($row['sr_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); ?> <html> <title>Stock Requisition</title> <head> <link rel="stylesheet" type="text/css" href="kanban.css"> <script type="text/javascript"> function save_sr(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var Items1 = document.getElementById("Items1").value; var SubItems = document.getElementById("SubItems").value; var ItemCode = document.getElementById("ItemCode").value; var DemandedQty = document.getElementById("DemandedQty").value; var UoM = document.getElementById("UoM").value; var Class = document.getElementById("Class").value; var Description = document.getElementById("Description").value; var BINLocation = document.getElementById("BINLocation").value; var RequestedBy = document.getElementById("RequestedBy").value; var ApprovedBy = document.getElementById("ApprovedBy").value; var ReceivedBy = document.getElementById("ReceivedBy").value; var IssuedBy = document.getElementById("IssuedBy").value; document.stock_requisition.action="StockRequisitionSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items1="+Items1+ "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+ Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+ "&IssuedBy="+IssuedBy; document.stock_requisition.submit(); alert("Stock Requisition data save."); window.location = "StockRequisition.php"; } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li> <li><a href="fsn.php" title="Finished Stock Note"><span>WMS FG</span></a></li> <li id="current"><a href="StockRequisition.php" title="WMS RM"><span>WMS RM</span></a></li> </ul> </div> <div id="ddcolortabs1"> <ul> <li><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><a href="Shelving.php" title="Shelving"><span>Shelving</span></a></li> <li id="current"><a href="StockRequisition.php" title="Stock Requisition"><span>Stock Requisition</span></a></li> </ul> </div> <div id="SR_date"> <label>Date :</label> <input type="text" name="sr_date" value="<?php echo $sr_date; ?>" size="16" readonly="readonly" style="border: none;"> </div> <div id="SR_number"> <label>SR# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="10" readonly="readonly" style="font-weight: bold; border: none;"> <br/> </div> <div> <table> <thead> <th>Items</th> <th>Sub Items</th> <th>Item Code</th> <th>Demanded Qty</th> <th>UoM</th> <th>Class</th> <th>Description</th> <th>BIN Location</th> </thead> <?php $sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items"; $res_bom = mysql_query($sql, $con); while($row = mysql_fetch_assoc($res_bom)){ $Items = $row['Items']; echo "<tr> <td style='border: none;font-weight: bold;'> <input type='name' value='$Items' name='Items' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='5'></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"or die(mysql_error()); $res_sub = mysql_query($sql, $con); while($row_sub = mysql_fetch_assoc($res_sub)){ $Items1 = $row_sub['Items']; $SubItems = $row_sub['SubItems']; $ItemCode = $row_sub['ItemCode']; $UoM = $row_sub['UoM']; $Class = $row_sub['Class']; $Description = $row_sub['Description']; $BINLocation = $row_sub['BINLocation']; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items1' id='Items1' name='Items1'></td> <td style='border: none;'> <input type='text' name='SubItems' value='$SubItems' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> <td style='border: none;'> <input type='text' name='ItemCode' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> <td style='border: none;'><center><input type='text' name='DemandedQty' id='DemandedQty' value='' size='7'></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td> <td style='border: none;'> <input type='text' name='Class' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> <td style='border: none;'> <input type='text' name='Description' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> <td style='border: none;'> <input type='text' name='BINLocation' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> </tr>"; } } ?> </table> </div> <?php $RequestedBy = array('AAA', 'BBB', 'CCC', 'DDD'); $ApprovedBy = array('EEE', 'FFF', 'GGG', 'HHH'); $ReceivedBy = array('III', 'JJJ', 'KKK', 'LLL'); $IssuedBy = array('MMM', 'NNN', 'OOO', 'PPP'); ?> <div id='Requested_By'> <label>Requested By:</label> <select name="RequestedBy"> <option value="Select">Select</option> <option value="AAA" <?php if($_POST['RequestedBy'] == 'AAA') echo "selected='selected'"; ?>>AAA</option> <option value="BBB" <?php if($_POST['RequestedBy'] == 'BBB') echo "selected='selected'"; ?>>BBB</option> <option value="CCC" <?php if($_POST['RequestedBy'] == 'CCC') echo "selected='selected'"; ?>>CCC</option> <option value="DDD" <?php if($_POST['RequestedBy'] == 'DDD') echo "selected='selected'"; ?>>DDD</option> </select> </div> <div id='Approved_By'> <label>Approved By:</label> <select name="ApprovedBy"> <option name='Select'>Select</option> <option value="EEE" <?php if($_POST['ApprovedBy'] == 'EEE') echo "selected='selected'"; ?>>EEE</option> <option value="FFF" <?php if($_POST['ApprovedBy'] == 'FFF') echo "selected='selected'"; ?>>FFF</option> <option value="GGG" <?php if($_POST['ApprovedBy'] == 'GGG') echo "selected='selected'"; ?>>GGG</option> <option value="HHH" <?php if($_POST['ApprovedBy'] == 'HHH') echo "selected='selected'"; ?>>HHH</option> </select> </div> <div id='Received_By'> <label>Issued By:</label> <select name="IssuedBy"> <option name='Select'>Select</option> <option value="III" <?php if($_POST['ReceivedBy'] == 'III') echo "selected='selected'"; ?>>III</option> <option value="JJJ" <?php if($_POST['ReceivedBy'] == 'JJJ') echo "selected='selected'"; ?>>JJJ</option> <option value="KKK" <?php if($_POST['ReceivedBy'] == 'KKK') echo "selected='selected'"; ?>>KKK</option> <option value="LLL" <?php if($_POST['ReceivedBy'] == 'LLL') echo "selected='selected'"; ?>>LLL</option> </select> </div> <div id='Issued_By'> <label>Received By:</label> <select name="ReceivedBy"> <option name='Select'>Select</option> <option value="MMM" <?php if($_POST['IssuedBy'] == 'MMM') echo "selected='selected'"; ?>>MMM</option> <option value="NNN" <?php if($_POST['IssuedBy'] == 'NNN') echo "selected='selected'"; ?>>NNN</option> <option value="OOO" <?php if($_POST['IssuedBy'] == 'OOO') echo "selected='selected'"; ?>>OOO</option> <option value="PPP" <?php if($_POST['IssuedBy'] == 'PPP') echo "selected='selected'"; ?>>PPP</option> </select> </div> <div id="save_btn"> <input type="button" name="button" value="save" onClick="save_sr()"> </div> </form> </body> </html> and here is StockRequisitionSave.php code for saving data to database : <?php error_reporting(0); date_default_timezone_set("Asia/Singapore"); //set the time zone $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); $sr_date = $_POST['sr_date']; $sr_number = $_POST['sr_number']; $Items1 = $_POST['Items1']; $SubItems = $_POST['SubItems']; $ItemCode = $_POST['ItemCode']; $DemandedQty = $_POST['DemandedQty']; $UoM = $_POST['UoM']; $Class = $_POST['Class']; $Description = $_POST['Description']; $BINLocation = $_POST['BINLocation']; $RequestedBy = $_POST['RequestedBy']; $ApprovedBy = $_POST['ApprovedBy']; $ReceivedBy = $_POST['ReceivedBy']; $IssuedBy = $_POST['IssuedBy']; $sql = "INSERT INTO stock_requisition (sr_date, sr_number, Items, SubItems, ItemCode, DemandedQty, UoM, Class, Description, BINLocation, RequestedBy, ApprovedBy, ReceivedBy, IssuedBy) VALUES ('$sr_date', '$sr_number', '$Items1', '$SubItems', '$ItemCode', '$DemandedQty', '$UoM', '$Class', '$Description', '$BINLocation', '$RequestedBy', '$ApprovedBy', '$ReceivedBy', '$IssuedBy') "; $result = mysql_query($sql, $con); ?> the problem is only the last data was save. I will attach my form. I hope somebody can help me.. I really don't know how can I save all data from form into my database. Thank you so much for your understanding and help. I was just wondering if it's possible to run a query on data that has been returned from a previous query? For example, if I do Code: [Select] $sql = 'My query'; $rs = mysql_query($sql, $mysql_conn); Is it then possible to run a second query on this data such as Code: [Select] $sql = 'My query'; $secondrs = mysql_query($sql, $rs, $mysql_conn); Thanks for any help Hi, I want to pull data from db, where sometimes all rows and sometimes rows matching given "username". Here is my code:
//Grab Username of who's Browsing History needs to be searched. if (isset($_GET['followee_username']) && !empty($_GET['followee_username'])) { $followee_username = $_GET['followee_username']; if($followee_username != "followee_all" OR "Followee_All") { $query = "SELECT * FROM browsing_histories WHERE username = \"$followee_username\""; $query_type = "followee_username"; $followed_word = "$followee_username"; $follower_username = "$user"; echo "$followee_username"; } else { $query = "SELECT * FROM browsing_histories"; $query_type = "followee_all"; $followed_word = "followee_all"; $follower_username = "$user"; echo "all"; } }
When I specify a "username" in the query via the url: browsing_histories_v1.php?followee_username=requinix&page_number=1 I see result as I should. So far so good.
Now, when I specify "all" as username then I see no results. Why ? All records from the tbl should be pulled! browsing_histories_v1.php?followee_username=all&page_number=1 This query shouldv'e worked:
$query = "SELECT * FROM browsing_histories";
I am trying to pass in a $string variable into my query like so but it is returning a warning: Code: [Select] $string = "clientName == '$input'"; $input = "Sam"; $table_id = 'booking'; $query ="SELECT * FROM booking WHERE. '$string' "; $test = mysql_query($query); echo $test; |