PHP - Beginner ?: What Is This Php Code Doing Inside This Form?
Hi all,
I am trying to replicate/modify this checkbox for a different script and I don't understand what the php code is doing in this form? Could someone explain to me whats happening by including that php code in the form? Code: [Select] <input type="checkbox" onclick="showArchive()" NAME="showarchive" id="showarchive" <?php echo ($showarchive ? 'checked="checked"' : '');?> /> Thanks! Similar TutorialsI have the following code in html: <html> <head> <script type="text/javascript"> <!-- function delayer(){ window.location = "http://VARIABLEVALUE.mysite.com" } //--> </script> <title>Redirecting ...</title> </head> <body onLoad="setTimeout('delayer()', 1000)"> <script type="text/javascript"> var sc_project=71304545; var sc_invisible=1; var sc_security="9c433fretre"; </script> <script type="text/javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript> <div class="statcounter"><a title="vBulletin statistics" href="http://statcounter.com/vbulletin/" target="_blank"><img class="statcounter" src="http://c.statcounter.com/71304545/0/9c433fretre/1/" alt="vBulletin statistics" ></a></div></noscript> </body> </html> Is a basic html webpage with a timer redirect script and a stascounter code. I know a bit about html and javascript, but almost nothing about php. My question is: How a can convert this html code into a php file, in order to send a variable value using GET Method and display this variable value inside the javascript code where says VARIABLEVALUE. Thanks in adavance for your help. Hi
I'm a beginner in php and are facing a problem i cant seem to find the correct solution on. $item5 = $_POST['PIGM1']; if (empty($item5)) { $email_body .= ''; } if (isset($item5)) { $email_body = '<html><head><style type="text/css">td { width: 450; }</style></head><body>'; $email_body .= '<table border="0" width="900">'; $email_body .= '<tr><td><strong>Header in table</strong></td><td></td></tr>'; $email_body .= '<tr><td><strong>Ordered</strong></td><td>' . $item5 . ' pcs. of some item</td></tr>'; $email_body .= '</table><br />'; } Can anyone help me in the right direction? I have a search box with an input box. When the user enters a string in this box and then when it clicks submit, the form needs to go to the http://ww.mywebsite.com/wp-content/uploads/<?php echo $_POST["name"]; ?>.jpg where $_POST["name"] is what the user entered. how to make it work?? <form action="http://ww.mywebsite.com/wp-content/uploads/<?php echo $_POST["name"]; ?>.jpg" method="post" target="_blank"> <!-- form fields here --> <INPUT TYPE = "Text" NAME = "name"> <input type="submit" /> </form> Hello, all! I am trying to learn PHP and MySQL on my own, and need some debugging help. What exactly is going wrong here? I am following a tutorial and trying to write the code as it says, but am still having trouble with syntax. Running a WAMP, PHP5.3, and MySQL5.5. This is my code: Code: [Select] <html> <body> <form name = "newVenue" method = "post"> Establishment name: <input type = "text" name = "name"> <br> Street Address: <input type = "text" name = "streetAddress"> <br> City: <input type = "text" name = "city"> <br> State: <select name="state"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="DC">DC</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> <br> Zip: <input type = "text" name = "zip"> <br> email: <input type = "text" name = "email"> <br> password: <input type = "text" name = "password"> <br> <input type="submit" name="Submit" value="Submit"> </form> <?php //If the form isn't empty, assign the value to a variable if (!empty($_POST['name'])) { $name = $_POST['name']; $address = $_POST['streetAddress']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $email = $_POST['email']; $password = $_POST['password']; //Connect to the 'Users' database and store the new bar into the 'Venue' table... mysql_connect ("localhost", "newbar", "Jpr5HJ2K5fWvPLXq") or die ('Oh, fuck: '.mysql_error()); mysql_select_db ("users"); $query = "INSTERT INTO venues VALUES ('NULL', 'testPic.jpg', '".$name."', '".$address."', '".$city."', '".$state."', '".$zip."', '".$email."', '".$password."', 0)"; mysql_query($query) or die ('Oh, fuck: '.mysql_error()); echo "Damn, Nathan. This shit actually worked..."; } ?> </body> </html>This is the error I receive: Code: [Select] Oh, fuck: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSTERT INTO venues VALUES ('NULL', 'testPic.jpg', 'Nathan's house', '666', 'DAY' at line 1This is my table: Code: [Select] id INT PRIMARY KEY pic_location VARCHAR name VARCHAR address VARCHAR city VARCHAR state VARCHAR zip VARCHAR email VARCHAR password VARCHAR event_name INT Any thoughts as to what is causing this error? Thanks in advance... How can I insert PHP code inside MySQL DB? I have mixed HTML and PHP code like this: <div class="rightpanel"> <div class="hltred"> <div class="hlthead"> <p><?php echo $pages->naslov; ?></p> </div> <div class="hltcontent"> <p> ovde treba da ide loop sa svi podlinkovi za taj glavni koji je aktivan</p> </div> </div> </div>, but when i insert it into DB i get this code (I use htmlspecialchars function to store): <div class="rightpanel"> <div class="hltred"> <div class="hlthead"> <p> <!--?php echo $pages---> naslov; ?></p> </div> <div class="hltcontent"> <p> ovde treba da ide loop sa svi podlinkovi za taj glavni koji je aktivan</p> </div> </div> </div> hi i have this form that runs with ASP. [this is a must since i didn't create that form] and must run in the wordpress header.php... is this even possible? Hello, I have a php code within a javascript. The javascript gets invoked on button click. The php code withing javascript never gets executed. I don't face the same problem in other browsers. Any help is much appreciated! Regards, Cole This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348601.0 Hello, people!
I was watching some php tutorials in youtube and, in a video, the guy was showing how put php script inside html code. I would like to know why in the following code he didn't use only one php script?
1- Code used in the video:
<html> <body> <?php $color = $_GET['clr']; ?> <b><font color="<?php echo $color;?>">This is a test.</font></b> </body> </html>2- Modified code by me to test with one script: <html> <body> <?php $color = $_GET['clr']; echo "<b><font color=\"$color\"> This is a test. </font></b>"; ?> </body> </html>Is his code more correct(with two scripts)? Why? Hi, I have this curl string required by an email verification vendor I use. Inside my php file I wish to run it. Apparently there is a problem with the syntax as I’m getting the following error in the browser: ”Parse error: syntax error, unexpected '--' (T_DEC) in /var/www/html/wp-content/plugins/dw_functionality_plugin/dw_functionality_plugin.phpon line 398 Here is the code string:
< > any help much appreciated! Edited March 23 by dwest100Hi. I created forms with condition to only view Items which is = Min Lot, now my problem is if no items that = Min Lot the select option below was displayed and the save button. I want to display them only also if the if condition is true. I mean if the condition was not satisfied no display, now in my code it happened is the Issued BY, Received By, Approved BY, Requested By and save button was still display.. How can I also display only them if the condition was satisfied? Thank you here is my code: <?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); ?> <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 Items_ = document.getElementById("Items_").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; var Items1 = document.getElementById("Items1").value; var SubQty_ = document.getElementsByTagName('input'); var SubQty = SubQty_[9].getAttribute("value"); var sr_number_hide = document.getElementById("sr_number_hide").value; document.frmMain.action="StockRequisitionSave1.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items_="+Items_+ "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+ Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+ "&IssuedBy="+IssuedBy+"&Items1="+Items1+"&sr_number_hide="+sr_number_hide+"&SubQty="+SubQty; document.frmMain.submit(); alert("Stock Requisition data save."); //window.location = "StockRequisition1.php"; window.location = "StockRequisitionDisplay1.php"; } </script> <script type="text/javascript"> function test_(cmpd, mult) { var len_ = (document.frmMain.elements.length) - 1; for (i=0; i <= len_; i++ ) { var cmp = "_" + cmpd; var strPos_ = document.frmMain.elements[i].id.indexOf(cmp) if (strPos_ != -1) { var strPos = document.frmMain.elements[i].id.indexOf("_"); var strId = document.frmMain.elements[i].id.slice(strPos + 1) + "_" + document.frmMain.elements[i].id.slice(0,strPos); document.frmMain.elements[i].value = (document.getElementById(strId).value * mult).toFixed(2); } } } </script> </head> <body> <form name="frmMain" method="post"> <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 $DemandedQty = $_POST['DemandedQty']; $sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items"; $res_bom = mysql_query($sql, $con); $totalDistinct = mysql_num_rows($res_bom); if ($totalDistinct > 0) { while ($row = mysql_fetch_assoc($res_bom)) { $Comp[] = substr($row['Items'], 12, 3); // $Comp = substr($cmpdArray, 12, 3); } } foreach ($Comp as $Comp) { $sql = "SELECT COUNT(WIP_1) AS WIP_1 FROM KANBAN_REPORT_OPEN WHERE SUBSTRING(LOT_CODE, 9) = '$Comp' AND WIP_1 > 0"; $resultWip = mysql_query($sql, $con); $wip_1 = mysql_result($resultWip, 0 , "WIP_1"); $wip1Accum = $wip1Accum + $wip_1; $sql = "SELECT COUNT(WIP_2) AS WIP_2 FROM KANBAN_REPORT_OPEN WHERE SUBSTRING(LOT_CODE, 9) = '$Comp' AND WIP_2 > 0"; $resultWip = mysql_query($sql, $con); $wip_2 = mysql_result($resultWip, 0 , "WIP_2"); $wip2Accum = $wip2Accum + $wip_2; $sql = "SELECT COUNT(WIP_3) AS WIP_3 FROM KANBAN_REPORT_OPEN WHERE SUBSTRING(LOT_CODE, 9) = '$Comp' AND WIP_3 > 0"; $resultWip = mysql_query($sql, $con); $wip_3 = mysql_result($resultWip, 0 , "WIP_3"); $wip3Accum = $wip3Accum + $wip_3; $sql = "SELECT COUNT(WIP_4) AS WIP_4 FROM KANBAN_REPORT_OPEN WHERE SUBSTRING(LOT_CODE, 9) = '$Comp' AND WIP_4 > 0"; $resultWip = mysql_query($sql, $con); $wip_4 = mysql_result($resultWip, 0 , "WIP_4"); $wip4Accum = $wip4Accum + $wip_4; $sql = "SELECT COUNT(WIP_5) AS WIP_5 FROM KANBAN_REPORT_OPEN WHERE SUBSTRING(LOT_CODE, 9) = '$Comp' AND WIP_5 > 0"; $resultWip = mysql_query($sql, $con); $wip_5 = mysql_result($resultWip, 0 , "WIP_5"); $wip5Accum = $wip5Accum + $wip_5; $total = $wip_1 + $wip_2 + $wip_3 + $wip_4 + $wip_5; $sql = "SELECT Compounds, Min_Lot FROM param_settings WHERE Compounds = '$Comp'"; $res_param = mysql_query($sql); $row_param = mysql_fetch_assoc($res_param); $Compounds = $row_param['Compounds']; $Min_Lot = $row_param['Min_Lot']; if($Comp = $Compounds && $total == $Min_Lot){ $sql = "SELECT DISTINCT Items FROM bom_subitems WHERE SUBSTR(Items,13,3) = '$Compounds' ORDER BY Items"; $res_bom = mysql_query($sql, $con); while($row = mysql_fetch_assoc($res_bom)){ $Items = $row['Items']; $Items_ = substr($Items, 12, 3); 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;'></td> <td style='border:none;'> </td> <td style='border:none;'> </td> <td style='border: none;'><center><input type='text' style='text-align: right;' name='DemandedQty[]' id='DemandedQty' size='12' onkeyup='test_(\"$Items_\", this.value)' value=''></center></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"or die(mysql_error()); $res_sub = mysql_query($sql, $con); $counter = 0; while($row_sub = mysql_fetch_assoc($res_sub)){ $joinId = $counter . "_" . $Items_; $Items = $row_sub['Items']; $Items1 = substr($Items, 12, 3); $SubItems = $row_sub['SubItems']; $ItemCode = $row_sub['ItemCode']; $UoM = $row_sub['UoM']; $Class = $row_sub['Class']; $Description = $row_sub['Description']; $BINLocation = $row_sub['BINLocation']; $Quantity = $row_sub['Quantity']; $joinId2 = $Items_ . "_" . $counter; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items1' name='Items1[]' id='Items1'></td> <td style='border: none;'> <input type='text' name='SubItems[]' id='SubItems' value='$SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='ItemCode[]' id='ItemCode' value='$ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td><input class='txt' type='text' name='SubQty[]' id='$joinId' readonly = 'readonly' size='12' style= 'border:none;text-align:right'/><input type='hidden' id='$joinId2' value='$Quantity' /></td> <td style='border: none;' size='3'> <input type='text' name='UoM[]' id='UoM' value='$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' name='Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></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= '30'></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;'></td> </tr>"; $counter = $counter + 1; } } } } ?> </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()" style="width: 5em;"> </div> </form> </body> </html> I will attach my sample form output Hey guys,
I'm facing an issue compiling the above stack from a source code inside lxc using centos 6.5 as a domain OS.
[lxc@lxc1 httpd-2.4.9]$ ./configure --with-included-apr checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configu configu Configuring Apache Portable Runtime library... configu configuring package in srclib/apr now checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Configuring APR library Platform: x86_64-unknown-linux-gnu checking for working mkdir -p... yes APR Version: 1.5.1 checking for chosen layout... apr checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configu error: in `/home/lxc/httpd-2.4.9/srclib/apr': configu error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details configure failed for srclib/apr This problem has been detected by me when I replaced my desktop machine with new one and installed a centOS again. This such a problem never happened before using my old machine with the same version of OS and libvirt. Just to be clear, a new selinux policy into a "domain machine" has been created to be able to use the "dbus daemon" to all containers and if I try to complile this stack from source using the "domain os" this problem never happens at all. All "Development tools" is installed to this particular container, in case someone asks me why I get the following error message - "configu error: cannot run C compiled programs" Any ideas? Edited by jazzman1, 08 June 2014 - 01:37 PM. Hey guys! Im trying to setup an IF statement on my home page. Its purpose is to show EITHER a login form and state your not logged in if it cannot find a stored cookie OR if it does find a stored cookie it will NOT show the HTML form and state you are logged in. I have it mostly working apart from the fact Im not sure how to insert a HTML form into PHP IF statement and make it work. Since I dont want the user to see the login form when they are already logged in. Here is a link to the php script: http://pastebin.com/aenq4gbE Here is link to the live page: http://jfbsystems.co.uk/secure Any help or ideas would be much appreciated! JellyFishBoy Hi there! I am wondering if anyone knows how to handle strings that contain form fields, so when the form is submitted the fields inside the string are updated. For example say i have the following $string: Code: [Select] please enter your username: <input type=text size=50 name=username value=" "> When I display it on the browser, inside of a form, it displays the blank text field. Say the user enters a value in the text field, "John", and hits submit. I need the $string to be updated to the following: Code: [Select] please enter your user name: <input type=text size=50 value="John"> I know it sounds wierd but I need the form to be inside of the string! Thanks in advance for any help! Hi, I have a (probably quite simple) question about passing form data to a php script that contains an iframe with another php script that also needs some of this form data. Basically, my problem is as follows: I have the following code in a file called example1.php: Code: [Select] <html> //some html stuff <?php if(isset($_POST['from'])) {$from1 = $_POST['from'];} else {$from1 = 'English';} $langList = array('English', 'French', 'German', 'Dutch'); print('<select id="from" name="from">'); foreach ($langList as $lang) {printf('<option %s>%s</option>', ($from1 == $lang ? 'selected="selected"' : ''), $lang); } echo '</select>'; ?> //some more html stuff </html> As you can see, it retrieves a variable via POST and selects its value from a list. The variable is posted from an html file (example0.htm) containing the following: Code: [Select] <form method="post" action="example1.php"> This worked fine, until I put example1.php inside an iframe in example2.php as follows: Code: [Select] <html> //some html here <?php //some php here ?> <iframe src ='example1.php' id='something' name='something' > </iframe> </html> and changed: "post" action="example2.php" in my html form. My question is: how do I pass form data from example0.htm to example2.php to example1.php, so that example2.php gets loaded when the submit button on my form gets pressed, but so that example1.php (which gets loaded from the iframe in example2.php) can also access the form data? Thanks! Hello all, thanks for everything you do! I used a php from generator to make the form seen on this page: http://www.firstpresgreenville.org/forms/retirementform/retirementform-alt.html I need to be able to click on the check boxes and get a dollar amount total in the total field....So if you checked "single", the total field would read $40, and if you checked on "couple", the field would read $50...simple as that... Is there anyway to make that happen? This is the code I am working with now.... <?php # This block must be placed at the very top of page. # -------------------------------------------------- require_once( dirname(__FILE__).'/form.lib.php' ); phpfmg_display_form(); # -------------------------------------------------- function phpfmg_form( $sErr = false ){ $style=" class='form_text' "; ?> <form name="frmFormMail" action='' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onsubmit();'> <input type='hidden' name='formmail_submit' value='Y'> <div id='err_required' class="form_error" style='display:none;'> <label class='form_error_title'>Please check the required fields</label> </div> <ol class='phpfmg_form' > <li class='field_block' id='field_0_div'><div class='col_label'> <label class='form_field'>Full Name(s)</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_0" id="field_0" value="<?php phpfmg_hsc("field_0"); ?>" class='text_box'> <div id='field_0_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_1_div'><div class='col_label'> <label class='form_field'>Street Address</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_1" id="field_1" value="<?php phpfmg_hsc("field_1"); ?>" class='text_box'> <div id='field_1_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_2_div'><div class='col_label'> <label class='form_field'>City</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_2" id="field_2" value="<?php phpfmg_hsc("field_2"); ?>" class='text_box'> <div id='field_2_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_3_div'><div class='col_label'> <label class='form_field'>State</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_3" id="field_3" value="<?php phpfmg_hsc("field_3"); ?>" class='text_box'> <div id='field_3_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_4_div'><div class='col_label'> <label class='form_field'>Zip Code</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_4" id="field_4" value="<?php phpfmg_hsc("field_4"); ?>" class='text_box'> <div id='field_4_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_5_div'><div class='col_label'> <label class='form_field'>Phone</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_5" id="field_5" value="<?php phpfmg_hsc("field_5"); ?>" class='text_box'> <div id='field_5_tip' class='instruction'>(###) ###-####</div> </div> </li> <li class='field_block' id='field_6_div'><div class='col_label'> <label class='form_field'>Email</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_6" id="field_6" value="<?php phpfmg_hsc("field_6"); ?>" class='text_box'> <div id='field_6_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_7_div'><div class='col_label'> <label class='form_field'>Number of Attendees</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_7" id="field_7" value="<?php phpfmg_hsc("field_7"); ?>" class='text_box'> <div id='field_7_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_8_div'><div class='col_label'> <label class='form_field'>Single or Couple?</label> <label class='form_required' >*</label> </div> <div class='col_field'> <?php phpfmg_checkboxes( 'field_8', "Single|Couple" );?> <div id='field_8_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_9_div'><div class='col_label'> <label class='form_field'>Amount Due</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_9" id="field_9" value="<?php phpfmg_hsc("field_9"); ?>" class='text_box'> <div id='field_9_tip' class='instruction'>$40/ single or $50/couple (Includes one book and lunch)</div> </div> </li> <li class='field_block' id='field_10_div'><div class='col_label'> <label class='form_field'>Additional Comments</label> <label class='form_required' > </label> </div> <div class='col_field'> <textarea name="field_10" id="field_10" rows=4 cols=25 class='text_area'><?php phpfmg_hsc("field_10"); ?></textarea> <div id='field_10_tip' class='instruction'></div> </div> </li> <?php phpfmg_dependent_dropdown( 'field_11' );?> <li> <div class='col_label'> </div> <div class='form_submit_block col_field'> <input type='submit' value='Submit' class='form_button'> <span id='phpfmg_processing' style='display:none;'> <img id='phpfmg_processing_gif' src='<?php echo PHPFMG_ADMIN_URL . '?mod=image&func=processing' ;?>' border=0 alt='Processing...'> <label id='phpfmg_processing_dots'></label> </span> </div> </li> </ol> </form> <?php phpfmg_javascript($sErr); } # end of form function phpfmg_form_css(){ ?> Thanks so much! Hi! My question is probably simple but I've been scratching my head for hours now... I'm pretty new to php. I have an online form for orders; when submitted, an email is sent to the shop manager containing the info the client has filled in. So I pass all the info in the code below, but I can't manage to echo the array containing the order's items/qty/item_code. (I'm using Wordpress, Oxygen Builder, Metabox and Code Snippets, if that helps). Here's the code (used as a Code Snippet):
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
$name = rwmb_meta( 'name', '', $post_id );
Nom: $name
$headers = ['Content-type: text/html', "Reply-To: $email"];
Help with this would be greatly appreciated! Please let me know if any details are missing. Thanks in advance! Jordan Edited June 23 by JordanCAdvance thank you. Can you help please. The error..... Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in C:\wamp\www\test_dabase.php on line 24 code. Code: [Select] <?php //database connection. $DB = mysql_connect("localhost","root") or die(mysql_error()); if($DB){ //database name. $DB_NAME="mysql"; //select database and name. $CON=mysql_select_db($DB_NAME,$DB)or die(mysql_error()."\nPlease change database name"); // if connection. }if($CON){ //show tables. $mysql_show="SHOW TABLES"; //select show and show. $mysql_select2="mysql_query(".$mysql_show.") or die(mysql_error())"; } //if allowed to show. if($mysql_select2){ //while it and while($data=mysql_fetch_assoc($mysql_select2)){ //show it. echo $data; } } ?> Hi, I need to insert some code into my current form code which will check to see if a username exist and if so will display an echo message. If it does not exist will post the form (assuming everything else is filled in correctly). I have tried some code in a few places but it doesn't work correctly as I get the username message exist no matter what. I think I am inserting the code into the wrong area, so need assistance as to how to incorporate the username check code. $sql="select * from Profile where username = '$username'; $result = mysql_query( $sql, $conn ) or die( "ERR: SQL 1" ); if(mysql_num_rows($result)!=0) { process form } else { echo "That username already exist!"; } the current code of the form <?PHP //session_start(); require_once "formvalidator.php"; $show_form=true; if (!isset($_POST['Submit'])) { $human_number1 = rand(1, 12); $human_number2 = rand(1, 38); $human_answer = $human_number1 + $human_number2; $_SESSION['check_answer'] = $human_answer; } if(isset($_POST['Submit'])) { if (!isset($_SESSION['check_answer'])) { echo "<p>Error: Answer session not set</p>"; } if($_POST['math'] != $_SESSION['check_answer']) { echo "<p>You did not pass the human check.</p>"; exit(); } $validator = new FormValidator(); $validator->addValidation("FirstName","req","Please fill in FirstName"); $validator->addValidation("LastName","req","Please fill in LastName"); $validator->addValidation("UserName","req","Please fill in UserName"); $validator->addValidation("Password","req","Please fill in a Password"); $validator->addValidation("Password2","req","Please re-enter your password"); $validator->addValidation("Password2","eqelmnt=Password","Your passwords do not match!"); $validator->addValidation("email","email","The input for Email should be a valid email value"); $validator->addValidation("email","req","Please fill in Email"); $validator->addValidation("Zip","req","Please fill in your Zip Code"); $validator->addValidation("Security","req","Please fill in your Security Question"); $validator->addValidation("Security2","req","Please fill in your Security Answer"); if($validator->ValidateForm()) { $con = mysql_connect("localhost","uname","pw") or die('Could not connect: ' . mysql_error()); mysql_select_db("beatthis_beatthis") or die(mysql_error()); $FirstName=mysql_real_escape_string($_POST['FirstName']); //This value has to be the same as in the HTML form file $LastName=mysql_real_escape_string($_POST['LastName']); //This value has to be the same as in the HTML form file $UserName=mysql_real_escape_string($_POST['UserName']); //This value has to be the same as in the HTML form file $Password= md5($_POST['Password']); //This value has to be the same as in the HTML form file $Password2= md5($_POST['Password2']); //This value has to be the same as in the HTML form file $email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file $Zip=mysql_real_escape_string($_POST['Zip']); //This value has to be the same as in the HTML form file $Birthday=mysql_real_escape_string($_POST['Birthday']); //This value has to be the same as in the HTML form file $Security=mysql_real_escape_string($_POST['Security']); //This value has to be the same as in the HTML form file $Security2=mysql_real_escape_string($_POST['Security2']); //This value has to be the same as in the HTML form file $sql="INSERT INTO Profile (`FirstName`,`LastName`,`Username`,`Password`,`Password2`,`email`,`Zip`,`Birthday`,`Security`,`Security2`) VALUES ('$FirstName','$LastName','$UserName','$Password','$Password2','$email','$Zip','$Birthday','$Security','$Security2')"; //echo $sql; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else{ mail('email@gmail.com','A profile has been submitted!',$FirstName.' has submitted their profile',$body); echo "<h3>Your profile information has been submitted successfully.</h3>"; } mysql_close($con); $show_form=false; } else { echo "<h3 class='ErrorTitle'>Validation Errors:</h3>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<p class='errors'>$inpname : $inp_err</p>\n"; } } } if(true == $show_form) { ?> |