PHP - Posting Values From An Input Field
I am having trouble sending information that was entered into a form, on the same page to the next page.
I am sure i have done this a few years ago but cant find the code and cant find the answer online, hope someone can help me. My code is as follows: <form method="POST" action="https://.............. .asp "> <table> <tr> <td>Name: </td> <td><input type="text" name="clientname" /></td> </tr> <tr> <td>E-mail:</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Contact No:</td> <td><input type="text" name="telno" /></td> </tr> </table> <?php $udate = date("y-m-d H:i:s", strtotime ("+2 hour")); $uniquevalue = "$udate" . " " . "Simpay Pro"; echo $uniquevalue; ?> <br /> <input type="hidden" name="info1" value="<?php print $uniquevalue?>"> <input type="hidden" name="info2" value=$clientname> <input type="submit" value="Submit"> </form> So basically info1 is working i can see the value on the next page after its submitted, but info2 is the value of the input field. Is this possible to do it like this, or do i have to send it to another page and then to my last page that displays the values? Similar TutorialsI have one field which is set up as a Text field in my database. What I'm wanting is if the field is blank in the form to just leave the field alone in the database. I need it to be NULL. OR...is there a way to query a database to recognize a field is blank? Hi all I have a form which takes details from drop down menus. But what I need is a wild card if someone leaves the selected option value as "all" it adjusts the SQL query to not search that cell so it brings all entries without filtering. My form looks like this: Code: [Select] <select name="area" id="area"> <option value="all">--All areas--</option> <?php $getareas = mysql_query (" SELECT * FROM `areas` ORDER by name ASC"); while ($showareas = mysql_fetch_array($getareas)) { ?> <option value="<?php echo $showareas['id']; ?>"><?php echo $showareas['name']; ?></option> <?php } ?> </select> My SQL query looks lie this: Code: [Select] $getads = mysql_query(" SELECT * FROM adverts WHERE categoryid = 1 AND areaid = '".$searchedarea."' AND makeid = '".$searchedmake."' AND modelid = '".$searchedmodel."' AND berth = '".$searchedberth."' AND live = 1 AND approved = 1 AND paid = 1 AND dateexpired >= '".$todaysdate."' ORDER BY seller ASC , type ASC, id ASC") or die (mysql_error()); So if they select 'all" in the drop down field, the SQL query doesn't have 'AND areaid = '".$searchedarea."'' in it? Is this possible, or can I add a wildcard into the SQL query? Many thanks Pete 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 karthicbabuany one? Hi, I got this form which passes hidden values as well as a select menu. The only thing is, it doesnt seem to post the form data to the script.
Here is the form
echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>"'; echo '<input type="hidden" name="listing_title" value="<?php echo $listing_title ?>"'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>"'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>"'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>"'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>"'; echo "<ul class='results'>"; echo '<li>Quantity:</li>'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; echo' </ul><br>'; echo '<div align="center">'; echo '<br>'; echo '<input type="submit" value="Confirm Purchase"><br>'; echo '</form><br>';And here is the script that the form is posted to <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to submit care guides"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; if (isset($_POST['listing_title'], $_POST['speciesCommon'], $_POST['cost'], $_POST['business'], $_POST['postage_cost'], $_POST['multipostage'], $_POST['quantity'] ) ) { if( $_POST['listing_title'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['speciesCommon'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['cost'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['business'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['postage_cost'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['multipostage'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['quantity'] == "" ) { echo "Error: Please go back and try again"; } else { $listing_title = mysqli_real_escape_string($con, $_POST['listing_title']); $speciesCommon = mysqli_real_escape_string($con, $_POST['speciesCommon']); $cost = mysqli_real_escape_string($con, $_POST['cost']); $business = mysqli_real_escape_string($con, $_POST['business']); $postage_cost = mysqli_real_escape_string($con, $_POST['postage_cost']); $multipostage = mysqli_real_escape_string($con, $_POST['multipostage'] ); $quantity = mysqli_real_escape_string($con, $_POST['quantity'] ); if( $multipostage == "per item" ) { $postage_cost = $quantity * $postage_cost; } elseif( $multipostage == "Combined Postage" ) { $postage_cost; } $total = $cost + $postage_costage; // Writes customer_sales information to the MySQL database $sqlCustomerSales = "INSERT INTO customer_sales(username, listing_title, speciesCommon, total, business, postage_cost, multipostage ) VALUES ( '". $username ."', '". $listing_title ."', '". $speciesCommon ."', '". $total ."', '". $business ."', '". $postage_cost ."', '". $multipostage."' )"; $result1 = mysqli_query($con, $sqlCustomerSales); // This writes the transaction to the MySQL database $memo = $listing_title; $datetime = date("Y-m-d H:i:s"); $regCustomerTransaction = "INSERT INTO customer_transactions(username, datetime, cost, postage_cost, memo) VALUES ( '". $username ."', '". $datetime ."', '". $cost ."', '". $postage_cost ."', '". $memo."' )"; // Query the database $result2 = mysqli_query($con, $regCustomerTransaction); } // This writes the user_stats to the MySQL database $total_items_sold = $quantity; $regUserStats = "INSERT INTO user_stats(username, datetime, total, items_listed, bonus_credits, last_credit_purchase, total_care_guides, total_items_sold, total_currently_listed_items, total_items_purchased, total_diary_entries, feedback ) VALUES ( '". $username ."', '". $datetime ."', '". $total ."', '". $quantity ."', '". $subtotal ."', '". $last_credit_purchase ."', '". $total_care_guides ."', '". $total_items_sold ."', '". $total_currently_listed_items ."', '". $total_items_purchased ."', '". $total_diary_entries ."', '". $feedback."' )"; // Query the database $result3 = mysqli_query($con, $regUserStats); } ?> <h1>Payment to <?php echo $username ?></h1><br> <?php echo '<strong>Thank you for confirming you would like to purchase $speciesCommon; </strong>'; echo '<br>'; echo '<strong>Your payment comes to a total of $total; </strong></h2>'; echo '<br>'; echo '<br>'; echo 'Please complete payment using the PayPal button<br>'; echo '<br>'; echo '<br>'; ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="shipping" value="<?php echo $postage_cost ?>"> <input type="hidden" name="business" value="<?php echo $business ?>"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="item_name" value="<?php echo $speciesCommon ?>"> <input type="hidden" name="amount" value="<?php echo $cost ?>"> <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" onclick="OnButton1(); OnButton2();" alt="PayPal – The safer, easier way to pay online." > <img alt="" align="center" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"></form> <?php } else { echo 'Sorry we were unable to process your listing. Please contact <a href="mailto:helpdesk@aquapetcentre.com?Subject=Listing%20error">helpdesk@aquapetcentre.com'; die(); include('includes/overall/footer.php'); } // Close the connection mysqli_close($con); ?><h1>Payment to <?php echo $username ?></h1><br> works, but I think that is because it is passed in the SESSION. Any other $variable such as those below echo '<strong>Thank you for confirming you would like to purchase $speciesCommon; </strong>'; echo '<br>'; echo '<strong>Your payment comes to a total of $total; </strong></h2>';does not work. Why is the form not posting the values to the database. Just in case it helps, the form gets its values from the database, and the values are displayed in the sales page on which the form is contained. Here is the page containing the form. <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to view this page!"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $business = $row['paypal_email']; $user_id = $_GET['user_id']; $results1 = $con->query("SELECT * FROM live_sales WHERE user_id = '$user_id';"); while($row = $results1->fetch_array()) { $username = $row['username']; $fishtype = $row['fishtype']; $speciesCommon = $row['speciesCommon']; $speciesScientific = $row['speciesScientific']; $listing_title = $row['listing_title']; $age = $row['age']; $quantity = $row['quantity']; $origin = $row['origin']; $size = $row['size']; $environment = $row['environment']; $waterChemistry = $row['waterChemistry']; $temperature = $row['temperature']; $feeding = $row['feeding']; $sexing = $row['sexing']; $compatability = $row['compatability']; $temperament = $row['temperament']; $breeding = $row['breeding']; $comments = $row['comments']; $postage_type = $row['postage_type']; $postage_cost = $row['postage_cost']; $multipostage = $row['multipostage']; $cost = $row['cost']; echo "<div class='result'>"; echo "<h3>$speciesCommon</h3>"; echo "<h2>$listing_title</h2>"; echo "<ul class='results'>"; echo "<li>Species</li>" . str_replace("_"," "," $fishtype") . "<br>"; echo "<li>Common Name:</li> $speciesCommon<br>"; echo "<li>Scientific Name:</li> $speciesScientific<br>"; echo "<li>Age:</li> $age<br>"; echo "<li>Quantity:</li> $quantity<br>"; echo "<li>Price per item:</li> £$cost<br>"; echo "<li>Origin:</li> $origin<br>"; echo "<li>Size:</li>$size<br>"; echo "<li>Environment:</li> $environment<br>"; echo "<li>Water Chemistry</li> $waterChemistry<br>"; echo "<li>Temperatu </li> $temperature<br>"; echo "<li>Feeding:</li> $feeding<br>"; echo "<li>Sexing:</li> $sexing<br>"; echo "<li>Compatability:</li> $compatability<br>"; echo "<li>Temperament:</li> $temperament<br>"; echo "<li>Breeding:</li>$breeding<br>"; echo "<li>Comments:</li> $comments<br>"; echo "<li>Postage Type:</li>$postage_type<br>"; echo "<li>Postage Cost:</li> £$postage_cost $multipostage<br>"; echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>"'; echo '<input type="hidden" name="listing_title" value="<?php echo $listing_title ?>"'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>"'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>"'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>"'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>"'; echo "<ul class='results'>"; echo '<li>Quantity:</li>'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; echo' </ul><br>'; echo '<div align="center">'; echo '<br>'; echo '<input type="submit" value="Confirm Purchase"><br>'; echo '</form><br>'; echo '<br><br> </div>'; exit(); } } echo 'Sorry but we could not find any results.'; } include 'includes/overall/footer.php'; ?>Any help is always appreciated. aquaman Code: [Select] header("Location: index.php?x=y") , i had seen people having this problem when i was asking too.. about adding GET values to a change header function... Anyone still need this help? Hi all, I have a situation where I need to remember what check boxes where checked over pagination, I have managed to do this via the use of this: http://jamesfunk.com/wordpress/?p=65 The problem is that as the code stood: Code: [Select] <input type="checkbox" name="compare" value="<?php echo $list['jobseeker_id'];?>" class="remember_cb"/> It was treating one ticked checkbox as them all because they all have the same name and are in the a while loop! I countered this by changing the code to: Code: [Select] <input type="checkbox" name="compare<?php echo $list['jobseeker_id']?>" value="<?php echo $list['jobseeker_id'];?>" class="remember_cb"/> Which effectively now makes the checkbox name unique... i.e. compare{id}. The problem with this is that I can now no longer process it. This is my processing code: $jobseekers = $_POST['compare']; $i = 0; for($i; $i<count($jobseekers); $i++){ $query = "SELECT * FROM jobseekers WHERE jobseeker_id = '$jobseekers[$i]'"; $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { // Spit out the required data } } As you can see I am trying to get the data from $_POST['compare'], which will obviously now be blank as I have had to make the name unique.... the trouble is I'm not sure how to actually process this. Can anyone help me out here? any help or advice would be greatly appreciated! many thanks, Greens85 I connected to a database. i want to know how i can get the value out of that field and add it to the values of another. i don't want to make any changes to the database. i just want to use the values for coding. please, if anyone knows how to do this, let me know. I have a field in a table named flights I hope to find a 1 line statement to bypass inserting a new row if $flight_no is already in the field flight_no btw flight_no is the primary key and won't allow a duplicate anyway but I want to avoid the error message this is what I tried but doesn't work if(SELECT * FROM flights WHERE flight_no !LIKE %$flight_no%) { can someone tell me why this won't work? I just want to key in the amtpaid and have fields inserted. I get no errors but the only field inserted is the datepaid . <html><head> <script> function $_(IDS) { return document.getElementById(IDS); } function calculate_paid() { var amtpaid = parseInt($_("amtpaid").value); var rentdue = parseInt($_("rentdue").value); var prevbal = parseInt($_("prevbal").value); var secdep = parseInt($_("secdep").value); var latechg = parseInt($_("latechg").value); var damage = parseInt($_("damage").value); var courtcost = parseInt($_("courtcost").value); var nsf = parseInt($_("nsf").value); var hudpay = parseInt($_("hudpay").value); var late = ($_("late").value); var paidsum = parseInt($_("paidsum").value); var dateNow = new Date(); var dayNow = dateNow.getDate(); var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear(); $_('datePaid').value = datePaid; if(dayNow > 5) { late = "L"; prevbal = prevbal + 10; } paidsum = paidsum + amtpaid var tentpay = amtpaid - hudpay; var totOwed = rentdue + prevbal - hudpay; var left = totOwed - amtpaid; if (amtpaid <= totOwed) { prevbal = left; } left = amtpaid - totOwed; if (left <= secdep) { secdep = secdep - left; } left = left - secdep; if (left <= damage) { damage = damage - left; } left = left - damage; if (left <= latechg) { latechg = latechg - left; } left = left - latechg; if (left <= courtcost) { courtcost = courtcost - left; } left = left - courtcost; if (left <= nsf) { nsf = nsf - left; } prevbal = left - nsf; } </script> </head><body> <?php mysql_connect(localhost,root,""); mysql_select_db(test) or die( "Unable to select database"); if(!empty($_POST["submit"])) { $apt = $_POST['apt']; $query="SELECT * FROM testdata Where apt='$apt'"; $result=mysql_query($query); if(mysql_num_rows($result)) { echo "<form action='#' method='post'><b>Rent Payment :<br /><br /> <table cellspacing=0 cellpadding=0 border=1> <tr> <th>Name</th> <th>Apt</th> <th>Paid</th> <th>Due</th> <th>Prev Bal</th> <th>Sec Dep</th> <th>Late Chg</th> <th>Dmg</th> <th>Court Cost</th> <th>NSF</th> <th>Tent Pay</th> <th>Hud Pay</th> <th>Date Paid</th> <th>Late</th> <th>Comments</th> <th>Paidsum</th> </tr>"; while($row = mysql_fetch_assoc($result)) { echo "<tr> <td><input type='text' size=25 name='name' value='" . $row['name'] . "'></td> <td><input type='text' size=2 name='apt' value='" . $row['apt'] . "' ></td> <td><input type='text' size=4 id='amtpaid' name='amtpaid' value='" . $row['amtpaid'] ."' onBlur='calculate_paid(this)'></td> <td><input type='text' size=4 id='rentdue' name='rentdue' value='" . $row['rentdue'] . "'></td> <td><input type='text' size=4 id='prevbal' name='prevbal' value='" . $row['prevbal'] ."'></td> <td><input type='text' size=4 id='secdep' name='secdep' value='" . $row['secdep'] ."'></td> <td><input type='text' size=4 id='latechg' name='latechg' value='" . $row['latechg'] ."'></td> <td><input type='text' size=4 id='damage' name='damage' value='" . $row['damage'] ."'></td> <td><input type='text' size=4 id='courtcost' name='courtcost' value='" . $row['courtcost'] ."'></td> <td><input type='text' size=4 id='nsf' name='nsf' value='" . $row['nsf'] ."'></td> <td><input type='text' size=4 id='tentpay' name='tentpay' value='" . $row['tentpay'] . "'></td> <td><input type='text' size=4 id='hudpay' name='hudpay' value='" . $row['hudpay'] ."'></td> <td><input type='text' size=10 id='datepaid' name='datepaid' value='" . $row['datepaid'] . "'></td> <td><input type='text' size=1 id='late' name='late' value='" . $row['late'] . "'></td> <td><input type='text' size=25 name='comments' value='" . $row['comments'] . "'></td> <td><input type='text' size=4 id='paidsum' name='paidsum' value='" . $row['paidsum'] . "'></td> </tr>"; } echo "</table> <input type='submit' name='update' value='Make Payment' /> </form>"; } else{echo "No listing for apartment $apt.<br />Please select another.<br />";} } if(!empty($_POST["update"])) { $sql = "UPDATE testdata SET name = '" . mysql_real_escape_string($_POST['name']) . "', amtpaid = '" . mysql_real_escape_string($_POST['amtpaid']) . "', rentdue = '" . mysql_real_escape_string($_POST['rentdue']) . "', prevbal = '" . mysql_real_escape_string($_POST['prevbal']) . "', secdep = '" . mysql_real_escape_string($_POST['secdep']) . "', latechg = '" . mysql_real_escape_string($_POST['latechg']) . "', nsf = '" . mysql_real_escape_string($_POST['nsf']) . "', damage = '" . mysql_real_escape_string($_POST['damage']) . "', courtcost = '" . mysql_real_escape_string($_POST['costcost']) . "', tentpay = '" . mysql_real_escape_string($_POST['tentpay']) . "', hudpay = '" . mysql_real_escape_string($_POST['hudpay']) . "', datepaid = '" . mysql_real_escape_string($_POST['datepaid']) . "', late = '" . mysql_real_escape_string($_POST['late']) . "', comments = '" . mysql_real_escape_string($_POST['comments']) . "', paidsum = '" . mysql_real_escape_string($_POST['paidsum']) . "' WHERE apt='".$_POST["apt"]."'"; mysql_query($sql) or die("Update query failed."); echo "Record for apartment ".$_POST["apt"]." has been updated"; } ?><form method="post" action="#"> <br /> <input type="text" name="apt"/> <p> <input type="submit" name="submit" value="select apartment"/> </form> </body></html> Hi All, Need help. I have a form which collect the users information including image which are stored in the directory. I want to rename the image file to the name of the user and stores it relative path in SQL table so that when I retrieve user name it also retrieve the image of the user. My Table structure is as follow: id int(5) lecturer_name varchar(10) lecturer_img_path varchar(100) Below is the PHP and HTML code. PHP Code <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'test'; mysql_select_db($dbname)or die ('Error connecting to mysql'); ?> <?php if(isset($_POST['lecturer'])) { $lecturer = $_POST['lecturer']; $n = count($lecturer); $i = 0; echo "Your selected lecturer are \r\n" . "<ol>"; while ($i < $n) { if($lecturer[$i] == ""){ //do nothing $i++; }else{ echo "<li>{$lecturer[$i]}</li> \r\n"; $i++; } } echo "</ol>"; } ?> <?php mysql_close($conn); ?> HTML FORM 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=utf-8" /> <title>lecturer details</title> <style type="text/css"> body { background-color: #ffc; } </style> </head> <body> <b> <h1>Enter new lecturer details :</h1> <form id="form1" name="form1" method="post" action="submit1.php"> <p>Lecturer:<br /> <label for="lecturer"></label> <input name="lecturer[]" type="text" id="lecturer1" size="15" /> <label for="lect_img1"></label><input id="lect_img1" type="file" name="lect_img[]"><br /> <input name="lecturer[]" type="text" id="lecturer2" size="15" /> <label for="lect_img2"></label><input id="lect_img2" type="file" name="lect_img[]"><br /> <input name="lecturer[]" type="text" id="lecturer3" size="15" /> <label for="lect_img3"></label><input id="lect_img3" type="file" name="lect_img[]"><br /> <input name="lecturer[]" type="text" id="lecturer4" size="15" /> <label for="lect_img4"></label><input id="lect_img4" type="file" name="lect_img[]"><br /> <input name="lecturer[]" type="text" id="lecturer5" size="15" /> <label for="lect_img5"></label><input id="lect_img5" type="file" name="lect_img[]"><br /> <input name="lecturer[]" type="text" id="lecturer6" size="15" /> <label for="lect_img6"></label><input id="lect_img6" type="file" name="lect_img[]"><br /> <br /> <input name="submit" type="submit" id="send" value="submit"> </form> </b> </body> </html> Hiya pplz. I am trying to add: class="keyboardInput" to activate a javascript script to an input box. This is the line im trying to add it to: <td><?php echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));?></td> I have tried: <td><?php echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));? class="keyboardInput"></td> didn't work. Any help would be great. Ian Ok I'm trying to select the pet with the current eggid in the url. That part works fine, but when I try to select more than one color, it gets all messed up. Because I don't know how to do it and I can't find it on the internet anywhere. Code: [Select] $sql = "SELECT * FROM pets WHERE eggid='".$_GET['eggid']."' AND color='blue' OR 'green' OR 'yellow' OR 'red'"; Does anyone know how to do that? Because whenever I put this: Code: [Select] $sql = "SELECT * FROM pets WHERE eggid='".$_GET['eggid']."' AND color='blue' OR color='yellow' OR color='green' OR color='red'"; It gets all messed up. It selects ALL the colors even if the eggid isn't the current eggid. So it displays the colors of all the pets that have those colors.. :/ EDIT: OR is this the only way I can do it: Code: [Select] $sql = "SELECT * FROM pets WHERE eggid='".$_GET['eggid']."' AND color='blue' OR eggid='".$_GET['eggid']."' AND color='green' OR eggid='".$_GET['eggid']."' AND color='yellow' OR eggid='".$_GET['eggid']."' AND color='red'"; Hi everyone. In the script below, I would like to have the input box for "Website" to have http:// already in that input field. So, people will see "Website:" and then in the input field it will have "http://" I'm a PHP novice, and I'm not sure how to do it. Thanks. Code: [Select] <?php $contact_form_fields = array( array('name' => 'Website:', 'type' => 'input', 'require' => 1), array('name' => 'Name:', 'type' => 'name', 'require' => 1), array('name' => 'E-mail:', 'type' => 'email', 'require' => 1), array('name' => 'Phone:', 'type' => 'input', 'require' => 0), array('name' => 'Service:', 'type' => 'select', 'require' => 1, 'default' => 'Select Desired Service', 'items' => array('Keyword Research', 'Search Engine Optimization', 'Link Building Services', 'SEO Web Design', 'SEO Copywriting', 'SEO Consulting', 'Conversion Optimization', 'Social Media and PR', 'Landing Page Optimization', 'Other')), array('name' => 'Budget:', 'type' => 'select', 'require' => 1, 'default' => 'Budget / Monthly', 'items' => array('$500-$1500', '$1500-$2500', '$2500-$5000', '$5000-$10000', '$10K +')), array('name' => 'Comments:', 'type' => 'textarea', 'require' => 1), array('name' => 'Turing number:', 'type' => 'turing', 'require' => 1, 'url' => 'contact-form/image.php', 'prompt' => 'Please enter the number displayed above'), ); $contact_form_graph = false; $contact_form_xhtml = true; $contact_form_email = "someone@somewhere.com"; $contact_form_encoding = "utf-8"; $contact_form_default_subject = "Sent from free SEO quote form"; $contact_form_message_prefix = "Sent from free SEO quote form\r\n==============================\r\n\r\n"; include_once "contact-form2/contact-form/contact-form.php"; ?> I have a register script, and I am wanting to make it so that if the username field contains, lets say "mod", "ass", and more, then it'll return an error and wont let them register. Hello phpfreaks I'm a bit new to PHP, as well as this forum. I'm learning in a fast way, but there's something I can't seem to figure out, nor find it on google. I'm sure it's a simple and basic trick, but like I said, I'm just a beginner So the question is: How can I store multiple words to an array, using only 1 input form field? I guess it's with a for-loop..? So everytime you hit the 'submit' button, a new word should be added to the array. My problem is that I'm always overwriting ONE word.. This is what I've got so far.. : Code: [Select] <?php if (isset($_POST['word'])){ $word = $_POST['word']; $word = strip_tags($word); $word = trim($word); $word = htmlentities($word); } else { $word = ""; } ?> <div id="arrays"> <p>Add a word to the array below:<br /><br /></p> <form action="index.php" method="post"> <input id="word" name="word" type="text" value="<?php echo $word; ?>" /> <br /><input class="btn" type="submit" value="Submit" /> </form> <br /> <p> <?php $array = array("apple", "banana", "lemon", $word); for ($i = 0; $i < count($array); $i++){ echo $array[$i] . " "; } ?> </p> </div> Also: I'm using PHP 5, in combination with xHTML strict 1.0. Can be those <input ...> types with values changed from a script ?. Imagine it like we have an admin and we want to change some input values with a generated form on that page instead of going source and changing 1 by 1 ? |