PHP - Form1 Field To Auto Populate Form2 Same Domain
Hi Everyone,
Please can you guide me to solving my issue: I have Form1 with fields one being the PK in mySQL (called callsign) Once I submit the data it enters into the DB no issues. I want to be able to take Form1.callsign once submitted, redirect and insert it into Form2.callsign Is this possible? I got the Redirect to work no problem after the data is inserted. I have been looking on Web and here and cant seem to find the answer to populate form2 from form1 field. Can I use a Variable somehow? I know there is an issue with submitting data to a 3rd party for security reasons etc, but I want when entering records on my own domain to autopopulate the next form with this callsign (which is the primary key) This way I get to link all 10 tables together using this key making the entire full record for the member. Any Assistance would be greatly appreciated. Thanks Allen Similar TutorialsHi. Pretty straight forward I guess but as the name suggests am a newbie. I have a form that requires the user to enter certain parameters. If the values are blank it submits to itself and loads the error messages. What I want to do is create PHP code that submits the form to a different url. What I thought was create two forms (the second with hidden fields replicating the first form), each form having a different url in the action"" code. What I cant work out is the PHP IF ELSE code to submit form 2 if Form1 is is validated correctly. This is the PHP code relevant to the form validation. Help? <?php //If form was submitted if ($_POST['submitted']==1) { $errormsg = ""; //Initialize errors if ($_POST[width]){ $title = $_POST[width]; //If title was entered } else{ $errormsg = "Please enter width"; } if ($_POST[drop]){ $textentry = $_POST[drop]; //If comment was entered } else{ if ($errormsg){ //If there is already an error, add next error $errormsg = $errormsg . " & content"; }else{ $errormsg = "Please enter drop"; } } } if ($errormsg){ //If any errors display them echo "<div class=\"box red\">$errormsg</div>"; } //If all fields present if ($title && $textentry){ //Do something echo 'THIS IS WHERE I WANT THE CODE TO SUBMIT FORM 2 or SUBMIT FORM 1 TO A DIFFERENT URL'; } ?> I am working on a web app, here's the page I am on : http://sa.uintramural.com/autoselect/timeslip.php The fields choices are being pulled from a database. What I am trying to do is when someone types in a name and selects that person that it would look in the table for the 'Terms' and pull whatever value there is for that person and choose it automatically in the drop down menu. Could you point me in the right direction to do that or show me a code snippet. Thanks I am trying to populate a custom field called "Customer Type" current user role. The custom field is displayed on my checkout page. I tried the below in my functions.php of my child theme and thought it would work but it does nothing. Can anyone tell me what I might be doing wrong?
$user = wp_get_current_user(); $fields['customertype'] = $user;
return $fields; add_filter( 'woocommerce_checkout_fields', 'onboarding_update_fields' ); Edited April 11 by JayXHey guys, I am a webmaster for my church and I am fairly new to PHP. What am trying to is when a visitor goes to our radio ministry page and clicks a button which the message number is displayed in the read only textbox, it will go to my request CD page and auto populate the message number in that text field form the readonly text field from the previous page. I will show my code for both pages for you to review. This is the Radio page (where I want to take the message number value from) 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="Living Word Community Church radio ministry" /> <meta name="keywords" content="reformed radio fort worth, reformed radio dallas, biblical radio fort worth, biblical radio dfw" /> <title>In Light of Scripture-Radio Ministry</title> <link href="_css/Main.css" rel="stylesheet" type="text/css" /> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="container"> <div class="header"><a href="index.php"><img src="_images/LWCCWeb.jpg" alt="Insert Logo Here" name="Insert_logo" width="960" height="200" id="Insert_logo" style="background: #D8BF78; display:block;" /></a> <?php include("_includes/header.php"); ?> <div class="sidebar1"> <p></p> <table width="150" border="0" cellpadding="10" align="left"> <tr> <td><a href="directions.php"><img src="_images/ChurchBox.png" width="150" height="125" alt="Directions" /></a></td> </tr> <tr> <td><img src="_images/Service Times.png" width="150" height="778" alt="Service Times" /></td> </tr> </table> <!-- end .sidebar1 --></div> <div class="content"> <div id="radio"></div> <table width="600" border="0" cellpadding="10"> <tr> <td><img src="_images/ILOS.png" width="600" height="111" alt="In Light of Scripture" /></td> </tr> <tr> <td style=" padding-top:25px"><p><font size="5"><b>In Light of Scripture</b> has been locally broadcast for more than 25 years.<br /> This Sunday morning radio program features the expositional teaching of Pastor Stan McGehee Jr. </font><p/></td> </tr> </table> <div id="mediagraph"><a href="http://kdkr.org" target="_blank"><img src="_images/kdkr.jpg" width="300" height="200" alt="Braodcast on KDKR 91.3 Sunday Mornings at 7:30" /></a></div> <br /><br /> <font size="2"><p align="center"><b>The sermon featured this week on "In Light of Scipture" is</b></p></font> <font size="2"><p align="center" style="color:#711726"><b><i>Peace Despite Tribulation</i></b></p></font> <div id="messagenumber" align="center"> <form action="" method="get" name="messagenumber"> <input name="" type="text" value="JR-843" size="6" readonly="readonly" /> <input name="GetMessage" type="button" value="Get Message" /> </form> </div> <!-- end .content --></div></div> <div class="sidebar2"> <table width="150" border="0" cellpadding="16" align="left"> <tr> <td><a href="reformation.php"><img src="_images/MenuBox1.png" width="150" height="125" alt="What Do We Mean by Reformed?" /></a></td> </tr> <tr> <td><a href="ServiceTimesAndCal.php"><img src="_images/MenuBox2.png" width="150" height="125" alt="Worship Service Schedule and Calendar" /></a></td> </tr> <tr> <td><a href="radio.php"><img src="_images/MenuBox3.png" width="150" height="125" alt="In Light of Scripture Radio Ministry" /></a></td> </tr> <tr> <td><a href="cable.php"><img src="_images/MenuBox4.png" width="150" height="125" alt="Living Word Today Cable Program" /></a></td> </tr> <tr> <td><a href="Sermons.php"><img src="_images/MenuBox5.png" width="150" height="125" alt="Listen to Sermons Online" /></a></td> </tr> <tr> <td><a href="http://www.lwcchurch.org/blog/" target="_blank"><img src="_images/MenuBox6.png" width= "150" height="125" alt="Read our reformed blog" /></a></td> </tr> </table> <!-- end .sidebar2 --></div> <?php include("_includes/footer.php"); ?> <!-- end .container --></div> <script type="text/javascript"> var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"}); var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"}); </script> </body> </html> This is for the CD request form. I want it to populate the Message# text field 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="Order Living Word Community Church sermons and teachings on CD" /> <meta name="keywords" content="Stan McGehee cd, Reformed teachings on cd, Biblical teachings on cd, LWCC cds" /> <title>Order CD's Online</title> <link href="_css/Main.css" rel="stylesheet" type="text/css" /> <link href="js/jquery.datepick.css" rel="stylesheet" type="text/css" /> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jquery/jquery-1.5.js"></script> <script type="text/javascript" src="js/jquery.datepick.js"></script> <script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationRadio.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $(function() { $('#popupDatepicker').datepick(); $('#inlineDatepicker').datepick({onSelect: showDate}); }); function showDate(date) { } </script> <link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" /> <link href="SpryAssets/SpryValidationRadio.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="container"> <div class="header"><a href="index.php"><img src="_images/LWCCWeb2.png" alt="Insert Logo Here" name="Insert_logo" width="960" height="200" id="Insert_logo" style="background: #D8BF78; display:block;" /></a> <?php include("_includes/header.php"); ?> <div class="sidebar1"> <p></p> <table width="150" border="0" cellpadding="10" align="left"> <tr> <td><a href="directions.php"><img src="_images/ChurchBox.png" width="150" height="125" alt="Directions" /></a></td> </tr> <tr> <td><img src="_images/Service Times.png" width="150" height="890" alt="Service Times" /></td> </tr> </table> <!-- end .sidebar1 --></div> <div class="content"> <h2 style="padding-left:50px"> Order messages on CD from LWCC</h2> <div id"form"> <form action="FormToEmail2.php" method="post"> <table width="550" border="0" cellpadding="10"> <tr> <td><table width="550" border="0" cellpadding="10"> <tr> <td width="190">First Name:</td> <td width="314"><span id="spryfirstname"> <input name="firstname" type="text" id="firstname" maxlength="20" /> <span class="textfieldMaxCharsMsg">Too many letters</span><span class="textfieldRequiredMsg">Enter first name </span></span></td> </tr> <tr> <td>Last Name:</td> <td><span id="sprylastname"> <input name="lastname" type="text" id="lastname" maxlength="20" /> <span class="textfieldRequiredMsg">Enter last name</span><span class="textfieldMaxCharsMsg">Too many letters</span></span></td> </tr> <tr> <td>Email<font size="2"> (So we can confirm if needed)</font>:</td> <td><span id="spryemail"> <input name="email" type="text" id="email" maxlength="50" /> <span class="textfieldRequiredMsg">Enter Email</span><span class="textfieldInvalidFormatMsg">Must be Email.</span><span class="textfieldMaxCharsMsg">Email too long</span></span></td> </tr> <tr> <td>Street:</td> <td><span id="sprystreet"><span id="sprystreet"> <input name="street" type="text" id="street" maxlength="50" /> <span class="textfieldRequiredMsg">Enter Street Address</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></td> </tr> <tr> <td>City:</td> <td><span id="sprycity"><span id="sprytextfield5"> <input name="City" type="text" id="city" maxlength="50" /> <span class="textfieldRequiredMsg">Enter your city</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span><span class="textfieldRequiredMsg">Enter Email</span><span class="textfieldInvalidFormatMsg">Must be Email.</span><span class="textfieldMaxCharsMsg">Email too lon</span></span></td> </tr> <tr> <td>Apartment number:</td> <td><span id="aptnum"> <input name="Apt number" type="text" id="aptnum" maxlength="6" width="80px" /> <span class="textfieldRequiredMsg">Enter Email</span><span class="textfieldInvalidFormatMsg">Must be Email.</span><span class="textfieldMaxCharsMsg">Email too long</span></span></td> </tr> <tr> <td>State:</td> <td><span id="spryselect1"> <select name="statelist"> <option value="null"></option> <option value="Alabama">AL</option> <option value="Alaska">AK</option> <option value="Arkansas">AR</option> <option value="Arizona">AZ</option> <option value="California">CA</option> <option value="Colorado">CO</option> <option value="Connecticut">CT</option> <option value="Deleware">DE</option> <option value="District of Columbia">DC</option> <option value="Florida">FL</option> <option value="Georgia">GA</option> <option value="Hawaii">HI</option> <option value="Idaho">ID</option> <option value="Iowa">IA</option> <option value="Illinois">IL</option> <option value="Indiana">IN</option> <option value="Kansas">KS</option> <option value="Kentucky">KY</option> <option value="Louisiana">LA</option> <option value="Massachusetts">MA</option> <option value="Maryland">MD</option> <option value="Maine">ME</option> <option value="Michigan">MI</option> <option value="Minnesota">MN</option> <option value="Missouri">MO</option> <option value="Mississippi">MS</option> <option value="Montana">MT</option> <option value="Nebraska">NE</option> <option value="New Hampshire">NH</option> <option value="New Jersey">NJ</option> <option value="New Mexico">NM</option> <option value="Nevada">NV</option> <option value="New York">NY</option> <option value="North Carolina">NC</option> <option value="North Dakota">ND</option> <option value="Ohio">OH</option> <option value="Oklahoma">OK</option> <option value="Oregon">OR</option> <option value="Pennslyvania">PA</option> <option value="Rhode Island">RI</option> <option value="South Carolina">SC</option> <option value="Tennessee">TN</option> <option value="Texas">TX</option> <option value="Utah">UT</option> <option value="Vermont">VT</option> <option value="Virginia">VA</option> <option value="Washington">WA</option> <option value="Wisconsin">WI</option> <option value="West Virginia">WV</option> <option value="Wyoming">WY</option> </select> <span class="selectRequiredMsg">Please select state</span></span></td> </tr> <tr> <td>Zip Code:</td> <td><span id="spryzip"><span id="sprytextfield6"> <input name="Zip Code" type="text" id="zip" maxlength="50" /> <span class="textfieldRequiredMsg">Enter Zip Code</span><span class="textfieldInvalidFormatMsg">Zip Code is 5 numbers.</span></span><span class="textfieldRequiredMsg">Enter Email</span><span class="textfieldInvalidFormatMsg">Must be Email.</span><span class="textfieldMaxCharsMsg">Email too lo</span></span></td> </tr> <tr> <td>Which Pastor or Teacher?</td> <td> <div id="spryradio1"> <table width="250"> <tr> <td><label> <input type="radio" name="Speaker" value="Pastor Stan McGehee" id="radiogroup_4" /> Pastor Stan McGehee Sr</label></td> </tr> <tr> <td><label> <input type="radio" name="Speaker" value="Pastor Stan McGehee Jr" id="radiogroup_5" /> Pastor Stan McGehee Jr</label></td> </tr> <tr> <td><label> <input type="radio" name="Speaker" value="Pastor Jack McFarland" id="radiogroup_6" /> Pastor Jack McFarland</label></td> </tr> <tr> <td><label> <input type="radio" name="Speaker" value="Steve Bader" id="radiogroup_7" /> Steve Bader</label></td> </tr> </table> <span class="radioRequiredMsg">Please select speaker</span></div></td> </tr> <tr> <td>Where did you hear message?</td> <td> <div id="spryradio2"> <table width="200"> <tr> <td><label> <input type="radio" name="How did you hear?" value="At LWCC" id="RadioGroup1_0" /> At our church</label></td> </tr> <tr> <td><label> <input type="radio" name="How did you hear?" value="On the Radio" id="RadioGroup1_1" /> On the Radio</label></td> </tr> <tr> <td><label> <input type="radio" name="How did you hear?" value="On Cable" id="RadioGroup1_2" /> On Cable</label></td> </tr> </table> <span class="radioRequiredMsg">Please make a selection</span></div></td> </tr> <tr> <td>What service?</td> <td><div id="spryradio3"> <table width="248"> <tr> <td width="240"><label> <input type="radio" name="When did you hear message?" value="Sunday AM" id="When did you hear message?_0" /> Sunday AM</label></td> </tr> <tr> <td><label> <input type="radio" name="When did you hear message?" value="Sunday PM" id="When did you hear message?_1" /> Sunday PM</label></td> </tr> <tr> <td><label> <input type="radio" name="When did you hear message?" value="Wednesday PM" id="When did you hear message?_2" /> Wednesday PM</label></td> </tr> <tr> <td><label> <input type="radio" name="When did you hear message?" value="Adult Sunday School" id="When did you hear message?_3" /> Adult Sunday School</label></td> </tr> </table> <span class="radioRequiredMsg">Please make a selection.</span></div></td> </tr> <tr> <td>Message Number <font size="2">(If known)</font>: </td> <td><input name="Message#" type="text" id="messagenumber" maxlength="50" /></td> </tr> </table> </td> </tr> <tr> <td><table width="550" border="0" cellpadding="10"> <h3 style="padding-left:135px">Please pick date of message</h3> <div id="selectdate" align="center"><input id="inlineDatepicker" name="When Did You Hear?" type="text" /></div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-4715900-1"); pageTracker._initData(); pageTracker._trackPageview(); </script></table></td> <tr> <td style="padding-left:250px"><input name="submit" value="Submit" type="submit" /> <input name="clearBtn" type="reset" /></td> </tr> </table> </td> </tr> </table> </form></div> <!-- end .content --></div></div> <div class="sidebar2"> <table width="150" border="0" cellpadding="25" align="left"> <tr> <td><a href="reformation.php"><img src="_images/MenuBox1.png" width="150" height="125" alt="What Do We Mean by Reformed?" /></a></td> </tr> <tr> <td><a href="ServiceTimesAndCal.php"><img src="_images/MenuBox2.png" width="150" height="125" alt="Worship Service Schedule and Calendar" /></a></td> </tr> <tr> <td><a href="radio.php"><img src="_images/MenuBox3.png" width="150" height="125" alt="In Light of Scripture Radio Ministry" /></a></td> </tr> <tr> <td><a href="cable.php"><img src="_images/MenuBox4.png" width="150" height="125" alt="Living Word Today Cable Program" /></a></td> </tr> <tr> <td><a href="Sermons.php"><img src="_images/MenuBox5.png" width="150" height="125" alt="Listen to Sermons Online" /></a></td> </tr> <tr> <td><a href="http://lwcchurch.blogspot.com" target="_blank"><img src="_images/MenuBox6.png" width="150" height="125" alt="Read our reformed blog" /></a></td> </tr> </table> <!-- end .sidebar2 --></div> <?php include("_includes/footer.php"); ?> <!-- end .container --></div> <script type="text/javascript"> var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"}); var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"}); var sprytextfield1 = new Spry.Widget.ValidationTextField("spryfirstname", "none", {validateOn:["blur"], maxChars:20}); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprylastname", "none", {maxChars:20, validateOn:["blur"]}); var sprytextfield3 = new Spry.Widget.ValidationTextField("spryemail", "email", {maxChars:50, validateOn:["blur"]}); var sprytextfield4 = new Spry.Widget.ValidationTextField("sprystreet", "none", {validateOn:["blur"], maxChars:50}); var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "none", {maxChars:50, validateOn:["blur"]}); var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {validateOn:["blur"]}); var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "zip_code", {validateOn:["blur"]}); var spryradio1 = new Spry.Widget.ValidationRadio("spryradio1"); var spryradio2 = new Spry.Widget.ValidationRadio("spryradio2"); var sprytextfield7 = new Spry.Widget.ValidationTextField("sprymessagenumber", "none", {isRequired:false}); var spryradio3 = new Spry.Widget.ValidationRadio("spryradio3"); </script> </body> </html> hey guys i can't seem to get my second list box to work? the first one is good it shows the brands but the second one does not show at all? i have 2 DB Brands and others products so in brands i have id and name .. second i have product_id-product_Nand Brand this is my query(select the brand then it list the products that are associated with the brand) <?php $Brand_N = $Product_N = null; //declare vars $conn = mysql_connect("localhost", "2", "2"); $db = mysql_select_db('2',$conn); if(isset($_POST["Brand_N"]) && is_numeric($_POST["Brand_N"])) { $Brand_N = $_POST["Brand_N"]; } if(isset($_POST["Product_N"]) && is_numeric($_POST["Product_N"])) { $Product_N = $_POST["Product_N"]; } ?> <script language="JavaScript"> function autoSubmit() { var formObject = document.forms['theForm']; formObject.submit(); } </script> <form name="theForm" method="post"> <select name="brand" onChange="autoSubmit();"> <option value="Brand">Brand</option> <?php $sql = "SELECT * FROM Brand"; $Brand = mysql_query($sql,$conn); while($row = mysql_fetch_array($Brand)) { echo ("<option value=\"$row[Brand_id]\" " . ($Brand_N == $row["Brand_N"]? " selected" : "") . ">$row[Brand_N]</option>"); } ?> </select> <?php if($Brand_N!= null && is_numeric($Brand_N)) { ?> <select name="Product" onChange="autoSubmit();"> <option value="Product">Product</option> <?php $sql = "SELECT * FROM products WHERE Brand = $Brand_N "; $Products = mysql_query($sql,$conn); while($row = mysql_fetch_array($Products)) { echo ("<option value=\"$row[Product_id]\" " . ($Product_N == $row["Product_N"]? " selected" : "") . ">$row[Products_N]</option>"); } ?> </select> </form> <?php } ?> original sql Code: [Select] -- -------------------------------------------------------- -- -- Table structure for table `countries` -- CREATE TABLE `countries` ( `id` int(6) NOT NULL auto_increment, `value` varchar(250) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=243 ; -- -- Dumping data for table `countries` -- INSERT INTO `countries` VALUES (1, 'Vancouver'); New Sql Code: [Select] -- -------------------------------------------------------- -- -- Table structure for table `countries` -- CREATE TABLE `countries` ( `id` int(6) NOT NULL auto_increment, `value` varchar(250) NOT NULL default '', `code` varchar(12) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=243 ; -- -- Dumping data for table `countries` -- INSERT INTO `countries` VALUES (1, 'Vancouver', 'BC-50'); PHP code for the job Code: [Select] <?php // PHP5 Implementation - uses MySQLi. // mysqli('localhost', 'yourUsername', 'yourPassword', 'yourDatabase'); $db = new mysqli('localhost', 'root' ,'password', 'weather'); if(!$db) { // Show error if we cannot connect. echo 'ERROR: Could not connect to the database.'; } else { // Is there a posted query string? if(isset($_POST['queryString'])) { $queryString = $db->real_escape_string($_POST['queryString']); // Is the string length greater than 0? if(strlen($queryString) >0) { // Run the query: We use LIKE '$queryString%' // The percentage sign is a wild-card, in my example of countries it works like this... // $queryString = 'Uni'; // Returned data = 'United States, United Kindom'; // YOU NEED TO ALTER THE QUERY TO MATCH YOUR DATABASE. // eg: SELECT yourColumnName FROM yourTable WHERE yourColumnName LIKE '$queryString%' LIMIT 10 $query = $db->query("SELECT your_column FROM your_db_table WHERE your_column LIKE '$queryString%' LIMIT 10"); if($query) { // While there are results loop through them - fetching an Object (i like PHP5 btw!). while ($result = $query ->fetch_object()) { // Format the results, im using <li> for the list, you can change it. // The onClick function fills the textbox with the result. // YOU MUST CHANGE: $result->value to $result->your_colum echo '<li onClick="fill(\''.$result->value.'\');">'.$result->value.'</li>'; } } else { echo 'ERROR: There was a problem with the query.'; } } else { // Dont do anything. } // There is a queryString. } else { echo 'There should be no direct access to this script!'; } } ?> What the original code does 1) you start typing your city (eg. Van) 2) when you type the first letter (eg. V), it looks into mysql and auto fills a dropdown menu with all possible cities What i need it to do 1) you start typing your city (eg. Van) 2) when you type the first letter (eg. V), it looks into mysql and auto fills a dropdown menu with all possible cities 3) when you find your city you click it or press enter, and it POST's the city code as well now how do i munipulate the script to do that... another thing, when i put the extra sql entry in "code", the auto fill stopped working, why? Thanks I have a form which creates a drop down list from data in a MySQL database. I would like to be able to have data from my database automatically populate based upon the selection from the list. How can I do that? Javascript? AJAX? Any help would be appreciated. Code: [Select] <?php $query2="SELECT tournament,id FROM 2011_Tournament"; $result2=mysql_query($query2); echo "<select name=2011_Tournament value='tournament'>Tournament</option>"; while($tournament=mysql_fetch_array($result2)){ echo "<option value='$tournament[tournament]'>$tournament[tournament]</option>"; } echo "</select>";?> Hi all,
How can i auto populate the price of an item based on a chosen product and then auto calculate the price and quantity before hitting the ADD button. The Unit price should be auto populated based on valu from the database. The amount is the Unit Price times the Quantity of the Product Selected. Thanks My form <form action="" method="post" data-toggle="validator"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>Item Name</label> <select id="username" name="item_name" class="form-control inputs" data-error="Select Item" required> <option value="">Chose Item</option> <?php $stmt = $pdo->query(" SELECT item_name FROM stocks ORDER BY item_name ASC "); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $item_name = $row['item_name']; echo "<option value=\"$item_name\"> $item_name </option>"; } ?> </select> <div class="help-block with-errors"></div> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>Unit Price</label> <input type="number" class="form-control" name="item_price"> <div class="help-block with-errors"></div> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>Item Quantity</label> <input type="number" class="form-control" name="item_qty" required data-error="Stock Quantity is missing"> <div class="help-block with-errors"></div> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>Amount</label> <input type="number" class="form-control" name="amount" > <div class="help-block with-errors"></div> </div> </div> </div> <br> <span class="input-group-btn"> <input name="send" type="submit" class="btn btn-danger btn-form display-4 rounded" value="ADD"> </span> </form>Edited May 4, 2019 by I-AM-OBODO Hi Good day Can someone pls help me regarding with this matter. I have a page for inserting records. And I have a combobox that is fetched through the specific field in database. I also have a table of records, for each row i have an href edit which throws the values to its respective texbox and combobox. THE PROBLEM is that when i click the href edit, the value from a selected row was not displayed from the combobox Is there a way to copy an auto-increment value (`id`) into another field in the same table (`org_id`)? So, when someone creates a new organization, it will copy the new auto-increment value into the org_id field. Is this possible? Thanks! This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=310894.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=323252.0 I have two domains both running SSL. Let's call them old-domain and new-domain. old-domain is permanently redirecting traffic to new-domain. There are still a lot of links out there to old-domain with https://. If I were to remove SSL from old-domain but keep SSL on new-domain, I am betting that users will be getting some sort of certificate error. Right? Any way around that if I want to remove SSL from old-domain?
This topic has been moved to the corner of 3rd Avenue and mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359430.0 I have read around and can't seem to find the right coding for what I need on this forum and some other other forums. I have a contact form (as listed below) and I need 2 locations (Print Name and Title) fields to auto-populate on a separate form (can be a doc, pdf, etc. any form of document which is easiest) and this form can be totally back end and the individual using the form never is going to see the form. It's going on a contract form, that we would like to auto-populate. Also is there a simple attachment code so individuals can attach documents to the code? <p style: align="center"><form action="mailtest.php" method="POST"> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> <div align="center"> <p class="style1">Name</p> <input type="text" name="name"> <p class="style1">Address</p> <input type="text" name="address"> <p class="style1">Email</p> <input type="text" name="email"> <p class="style1">Phone</p> <input type="text" name="phone"> <p class="style1">Debtor</p> <input type="text" name="debtor"> <p class="style1">Debtor Address</p> <input type="text" name="debtora"> <br /> <br /> <a href="authoforms.php" target="_blank" style="color:#ffcb00" vlink="#ffcb00">Click here to view Assignment Agreement and Contract Agreement</a> <p class="style1"><input type='checkbox' name='chk' value='I Have read and Agree to the terms.'> I have read and agree to the Assignment and Contract Agreement <br></p> <p class="style1">Print Name</p> <input type="text" name="pname"> <p class="style1">Title</p> <input type="text" name="title"> <p class="style1">I hear by agree that the information I have provided is true, accurate and the information I am submitting is <br /> not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms:</p> <select name="agree" size="1"> <option value="Agree">Agree</option> <option value="Disagree">Disagree</option> </select> <br /> <br /> <p class="style1">Employee ID:</p> <input type="text" name="employee"> <br /> <input type="submit" value="Send"><input type="reset" value="Clear"> </div> </form> </p> The mailtest php is this ?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $name = $_POST['name']; $address = $_POST['address']; $email = $_POST['email']; $phone = $_POST['phone']; $debtor = $_POST['debtor']; $debtora = $_POST['debtora']; $value = $_POST['chk']; $pname = $_POST['pname']; $title = $_POST['title']; $agree = $_POST['agree']; $employee = $_POST['employee']; $formcontent=" From: $name \n Address: $address \n Email: $email \n Phone: $phone \n Debtor: $debtor \n Debtor's Address: $debtora \n 'Client' has read Assignment and Contract Agreement: $value \n Print Name: $pname \n Title: $title \n I hear by agree that the information I have provided is true, accurate and the information I am submitting is not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms: $agree \n \n Employee ID: $employee \n IP: $ip"; $recipient = "mail@crapower.com"; $subject = "Online Authorization Form 33.3%"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!" . " -" . "<a href='index.php' style='text-decoration:none;color:#ffcb00;'> Return Home</a>"; $ip = $_POST['visitoraddress'] ?> //php code <?php include_once('con.php'); if(!empty($_GET['search'])) { $search = $connect->prepare('SELECT * FROM posts WHERE title LIKE :search'); $search->bindValue(':search', '%'.$_GET['search'].'%', PDO::PARAM_STR); $search->execute(); ?> <?php while($row = $search->fetch()) {?> <li class="result" onClick="searchValue('<?php echo $row['title'];?>')"><?php echo $row['title'];?></li> <?php } ?> <?php } ?> //ajax $('#inputsch').keyup(function(){ $.ajax({ type: 'GET', url: 'fetch.php', data:'search='+$(this).val(), success: function(data){ $('#box').show(); $('#box').html(data); } }); }); }); function searchValue(val) { $('#inputsch').val(val); $('#box').hide(); } //search box <form action="search.php"> <input id="inputsch" type="text" name="search" placeholder="search..." autocomplete="off" autofocus> <button type="submit" value="search" >search</button> </form> <div id="box"></div> //the problem here is when i click the result is only added to input, but i want it to autosubmit
So a project I have simply to learn how it is done is to make an auto updating sitemap with a auto submitter. I have been doing a little research on sitemaps but haven't found much in the way of a tutorial or white paper or similar, anyway I was wondering if I am on the right track or not. What I was thinking for the auto-updating sitemap is since site maps are XML, when an article is published using my custom CMS/Blogging system, I make it rewrite the sitemap appending the new URL that will be generated. Then for the auto-submit, I can either make it a cron job or just manual press, but it would go though a for list of URLs, replacing the end part with my site map url. I think that is how it would be done. If you have a better idea, or can point out an article so I can understand a lot more with sitemaps, I will appreciate it, I am trying to learn as much as possible, I have gone to the offical website (sitemaps.org) but it doesn't have what I am looking for. Thanks, James This is my first real jump into PHP, I created a small script a few years ago but have not touched it since (or any other programming for that matter), so I'm not sure how to start this. I need a script that I can run once a day through cron and take the date from one table/filed and insert it into a different table/field, converting the human readable date to a Unix date. Table Name: Ads Field: endtime_value (human readable date) to Table Name: Node Field: auto_expire (Converted to Unix time) Both use a field named "nid" as the key field, so the fields should match each nid field from one table to the next. Following a tutorial I have been able to insert into a field certain data, but I don't know how to do it so the nid's match and how to convert the human readable date to Unix time. Thanks in advance!. Hi: I'm going crazy trying to do the following: I'm making a job registration process where the user registers on one php page to the website, must acknowlege and email receipt using an activate php page, then is directed to upload their C.V. (resume) based on the email address they enter in the active page output. I then run an upload page to store the resume in teh MySQL db based on the users email address in the same record. If I isolate the process of the user registering to the db, it works perfectly. If I isolate the file upload process into the db, it works perfect. I simply cannot upload teh file to the existing record based on teh email form field matching the user_email field in the db. With the processes together, teh user is activated, but teh file is not uploaded. Maybe I've simply been at this too long today, but am compeled to get through it by end day. If anyone can help sugest a better way or help me fix this, I will soo greatly appreciate it. My code is as follows for the 2 pages. ---------activate.php------- <?php session_start(); include ('reg_dbc.php'); if (!isset($_GET['usr']) && !isset($_GET['code']) ) { $msg = "ERROR: The code does not match.."; exit(); } $rsCode = mysql_query("SELECT activation_code from subscribers where user_email='$_GET[usr]'") or die(mysql_error()); list($acode) = mysql_fetch_array($rsCode); if ($_GET['code'] == $acode) { mysql_query("update subscribers set user_activated=1 where user_email='$_GET[usr]'") or die(mysql_error()); echo "<h3><center>Thank You! This is step 2 of 3. </h3>Your email is confirmed. Please upload your C.V. now to complete step 3.</center>"; } else { echo "ERROR: Incorrect activation code... not valid"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Job application activation</title> </head> <body> <center> <br/><br/><br/> <p align="center"> <form name="form1" method="post" action="upload.php" style="padding:5px;"> <p>Re-enter you Email : <input name="email" type="text" id="email"/></p></form> <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="4000000"> Upload your C.V.: <input name="userfile" type="file" id="userfile"> <input name="upload" type="submit" id="upload" value="Upload your C.V."/></form> </p> </center> </body> </html> --------upload.php---------- <?php session_start(); if (!isset($_GET['usr']) && !isset($_GET['code']) ) { $msg = "ERROR: The code does not match.."; exit(); } if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $email = $_POST['email']['user_email']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } include 'reg_dbc.php'; $query = "UPDATE subscribers WHERE $email = user_email (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); mysql_close($dbname); } ?> <center> <br/> <br/> <br/> <br/> Thank you for uploading your <?php echo "$fileName"; ?> file, completing your registration, and providing us your C.V. for this position. <br/> <br/> <br/> We will contact you if your canditature qualifies. </center> |