PHP - Form Filling Issue
Ok so I have a few check box fields that are dynamically populated from a database. What I need to do is check the box if it is a selected value(this is an edit form for a product) so here's what I have but it is not working.
Code: [Select] <?php include("../../../cart/includes/openDbConn.php"); $sql = "SELECT Name FROM FabricType"; $result = mysql_query($sql); $gettype = 'SELECT Type FROM FabricsTypes WHERE SKU = "'.$sku.'";'; $dogettype = mysql_query($gettype); $vtype = mysql_fetch_assoc($dogettype); $count = count($vtype); $i = 0; while($row = mysql_fetch_array($result)){ if( $i % 3 == 0 ) { echo '</tr><tr>'; } while($vtype = mysql_fetch_assoc($dogettype)){ if($vtyp['Type'] == $row['Name']){ echo '<td><label><input type="checkbox" name="typeGroup1[]" checked="checked" value="'.trim($row["Name"]).'">'.trim(ucfirst($row["Name"])).'</label</td>'; }else{ echo '<td><label><input type="checkbox" name="typeGroup1[]" value="'.trim($row["Name"]).'">'.trim(ucfirst($row["Name"])).'</label</td>'; } } $i++; } ?> When I do this it echoes nothing out. Similar Tutorialsi want to make a forum that nobody can fill that through any software automatically i make this one with java script authentications but some one also make a break of this and and he fill this software only in one click with automatic way this one which i make http://www.ebs-ads.com/advertising/forms.php?id=4&name=Abel any better solutions using php or any other function that users must have to post every input field separately manually ..if yes Please suggest me thanks hi everyone, Im trying to make a checkout page, where if the user is logged in, the address information is called from the database and fills the form automatically, my problem is i don't know how to fill the php variables with the result of my sql query..sorry to be a complete noob but can someone explain how i would do this? <?php if (!defined('WEB_ROOT') || !isset($_GET['step']) || (int)$_GET['step'] != 1) { exit; } require_once 'loginfunctions.php'; checkCustomerLogin(); $errorMessage = ' '; ?> <?php // get the customer id from the session. $cu_id = $_SESSION['cu_id'] ?> <?php //connect to server $mysqli = mysqli_connect("localhost", "root", "", "onlinestore"); //get default shipping and payment address $mysql = "SELECT cu_id,od_shipping_first_name,od_shipping_last_name,od_shipping_address1,od_shipping_address2,od_shipping_phone,od_shipping_city,od_shipping_state,od_shipping_postal_code FROM tbl_customer WHERE $cu_id = cu_id"; $result = mysqli_query($mysql,$mysqli); $row = mysql_fetch_assoc($result); //populate form with values ? $txtShippingFirstName = 'test'; $txtShippingLastName = 'test'; $txtShippingAddress1 = 'test'; $txtShippingAddress2 = 'test'; $txtShippingPhone = 'test'; $txtShippingState = 'test'; $txtShippingCity = 'test'; $txtShippingPostalCode = 'test'; ?> <script language="JavaScript" type="text/javascript" src="library/checkout.js"></script> <table width="550" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td>Step 1 Of 3 : Please Confirm Shipping And Payment Information </td> </tr> </table> <p id="errorMessage"><?php echo $errorMessage; ?></p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?step=2" method="post" name="frmCheckout" id="frmCheckout" onSubmit="return checkShippingAndPaymentInfo();"> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td colspan="2">Shipping Information</td> </tr> <tr> <td width="150" class="label">First Name</td> <td class="content"><input name="txtShippingFirstName" type="text" class="box" id="txtShippingFirstName" value="<?php echo $txtShippingFirstName ?>" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Last Name</td> <td class="content"><input name="txtShippingLastName" type="text" class="box" id="txtShippingLastName" value="<?php echo $txtShippingLastName ?>" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Address1</td> <td class="content"><input name="txtShippingAddress1" type="text" class="box" id="txtShippingAddress1" value="<?php echo $txtShippingAddress1 ?>" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Address2</td> <td class="content"><input name="txtShippingAddress2" type="text" class="box" id="txtShippingAddress2" value="<?php echo $txtShippingAddress2 ?>" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Phone Number</td> <td class="content"><input name="txtShippingPhone" type="text" class="box" id="txtShippingPhone" value="<?php echo $txtShippingPhone ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Province / State</td> <td class="content"><input name="txtShippingState" type="text" class="box" id="txtShippingState" value="<?php echo $txtShippingState ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">City</td> <td class="content"><input name="txtShippingCity" type="text" class="box" id="txtShippingCity" value="<?php echo $txtShippingCity ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Postal / Zip Code</td> <td class="content"><input name="txtShippingPostalCode" type="text" class="box" id="txtShippingPostalCode" value="<?php echo $txtShippingPostalCode ?>" size="10" maxlength="10"></td> </tr> </table> <p> </p> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td width="150">Payment Information</td> <td><input type="checkbox" name="chkSame" id="chkSame" value="checkbox" onClick="setPaymentInfo(this.checked);"> <label for="chkSame" style="cursor:pointer">Same as shipping information</label></td> </tr> <tr> <td width="150" class="label">First Name</td> <td class="content"><input name="txtPaymentFirstName" type="text" class="box" id="txtPaymentFirstName" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Last Name</td> <td class="content"><input name="txtPaymentLastName" type="text" class="box" id="txtPaymentLastName" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Address1</td> <td class="content"><input name="txtPaymentAddress1" type="text" class="box" id="txtPaymentAddress1" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Address2</td> <td class="content"><input name="txtPaymentAddress2" type="text" class="box" id="txtPaymentAddress2" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Phone Number</td> <td class="content"><input name="txtPaymentPhone" type="text" class="box" id="txtPaymentPhone" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Province / State</td> <td class="content"><input name="txtPaymentState" type="text" class="box" id="txtPaymentState" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">City</td> <td class="content"><input name="txtPaymentCity" type="text" class="box" id="txtPaymentCity" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Postal / Zip Code</td> <td class="content"><input name="txtPaymentPostalCode" type="text" class="box" id="txtPaymentPostalCode" size="10" maxlength="10"></td> </tr> </table> <p> </p> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr> <td width="150" class="entryTableHeader">Payment Method </td> <td class="content"> <input name="optPayment" type="radio" id="optPaypal" value="paypal" checked="checked" /> <label for="optPaypal" style="cursor:pointer">Paypal</label> <input name="optPayment" type="radio" value="cod" id="optCod" /> <label for="optCod" style="cursor:pointer">Cash on Delivery</label></td> </tr> </table> <p> </p> <p align="center"> <input class="box" name="btnStep1" type="submit" id="btnStep1" value="Proceed >>"> </p> </form> I am trying to convert and old website from mysql database to sqlite. One of the chores it must do is collect information from the database and put it in a list/menu select box on a page so the user can choose which item to pursue.
In the following (incomplete) snippit, I am doing something incorrectly because the sql query does get the proper information (I can put it in a table on the page just fine). But I'm having trouble getting the information into the select options on a list/menu. It appears to be putting them all, one after the other in the first option spot. The last one seems to be the only one of 6 or 7 that shows up.
It's been 10 or 12 years since I've messed with php, so I think I'm way behind... any help would be appreciated.
---------------------------
<form action="sqlPropDisplay.php" method="post" id="Residential"> Here's my code, whenever I try to fill the form it gives me that error "Oops! Something went wrong. Please try again later"
Code: <?php // Include config file require_once "config.php"; // Define variables and initialize with empty values $CodEntrega = $CodCliente = $Dia = $Pagamento = $Funcionario = ""; $CodEntrega_err = $CodCliente_err = $Dia_err = $Pagamento_err = $Funcionario_err = ""; // Processing form data when form is submitted if($_SERVER["REQUEST_METHOD"] == "POST"){ // Validate name $input_CodEntrega = trim($_POST["CodEntrega"]); if(empty($input_CodEntrega)){ $CodEntrega_err = "Insira o codigo de entrega"; } else{ $CodEntrega = $input_CodEntrega; } // Validate address $input_CodCliente = trim($_POST["CodCliente"]); if(empty($input_CodCliente)){ $CodCliente_err = "Insira o codigo do cliente"; } else{ $CodCliente = $input_CodCliente; } // Validate salary $input_Dia = trim($_POST["Dia"]); if(empty($input_Dia)){ $Dia_err = "Insira a data da entrega"; } else{ $Dia = $input_Dia; } $input_Pagamento = trim($_POST["Pagamento"]); if(empty($input_Pagamento)){ $Pagamento_err = "Insira o tipo de pagamento"; } else{ $Pagamento = $input_Pagamento; } $input_Funcionario = trim($_POST["Funcionario"]); if(empty($input_Funcionario)){ $Funcionario_err = "Insira o codigo do funcionario"; } else{ $Funcionario = $input_Funcionario; } if(empty($CodEntrega_err) && empty($CodCliente_err) && empty($Dia_err) && empty($Pagamento_err) && empty($Funcionario_err)){ $sql = "INSERT INTO entrega(CodEntrega, CodCliente, Dia, Pagamento, Funcionario) VALUES (?, ?, ?, ?, ?)"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "ssdss", $param_CodEntrega, $param_CodCliente, $param_Dia, $param_Pagamento, $param_Funcionario); // Set parameters $param_CodEntrega= $CodEntrega; $param_CodCliente = $CodCliente; $param_Dia = $Dia; $param_Pagamento = $Pagamento; $param_Funcionario = $Funcionario; if(mysqli_stmt_execute($stmt)) { header("location: home.html"); exit(); } else { echo "Oops! Something went wrong. Please try again later."; } } // Close statement mysqli_stmt_close($stmt); } // Close connection mysqli_close($link); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Projeto TW</title> <link rel="stylesheet" href="css/milligram.css"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * { box-sizing: border-box; } body { font-family: Arial, Helvetica, sans-serif; } /* Style the header */ header { background-color: #B0171F; padding: 30px; text-align: center; font-size: 35px; color: white; } /* Create two columns/boxes that floats next to each other */ nav { float: left; width: 30%; height: 300px; /* only for demonstration, should be removed */ background: #ccc; padding: 20px; } /* Style the list inside the menu */ nav ul { list-style-type: decimal; padding: 0; } article { float: left; padding: 20px; width: 70%; background-color: #f1f1f1; height: 300px; /* only for demonstration, should be removed */ } /* Clear floats after the columns */ section::after { content: ""; display: table; clear: both; } /* Style the footer */ footer { background-color: #B0171F; padding-top: 7px; padding-bottom: 7px; text-align: middle; color: white; position: relative; bottom: 0; } #content-wrap { padding-bottom: 2rem; /* Footer height */ } #page-container { position: relative; } @media (max-width: 600px) { nav, article { width: 100%; height: auto; } } .dropbtn { background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; } .dropdown { position: relative; display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #f1f1f1; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-content a:hover {background-color: #ddd;} .dropdown:hover .dropdown-content {display: block;} .dropdown:hover .dropbtn {background-color: #3e8e41;} </style> </head> <body> <header> <div class="head1">PROJETO DE TW</div> <div class="head2">Gestão de uma BD</div> </header> <div class='container'> <div class='navbar'> <ul> <li><a class="active" href="home.html">Home</a></li> <li><a href="#consultar">Consultar</a></li> <li><a href="tabela.html">Inserir</a></li> <li><a href="#alterar">Alterar</a></li> <li><a href="#eliminar">Eliminar</a></li> </ul> </div> <div class = "body_sec"> <section id="Content"> <h3>INSERIR DADOS DE ENTREGA</h3> <button type="button" >ENTREGA</button> </section> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post"> <div class="form-group"> <label>CodEntrega</label> <input type="text" name="CodEntrega" class="form-control <?php echo (!empty($CodEntrega_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $CodEntrega; ?>"> <span class="invalid-feedback"><?php echo $CodEntrega_err;?></span> </div> <div class="form-group"> <label>CodCliente</label> <input type="text" name="CodCliente" class="form-control <?php echo (!empty($CodCliente_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $CodCliente; ?>"> <span class="invalid-feedback"><?php echo $CodCliente_err;?></span> </div> <div class="form-group"> <label>Dia de Entrega</label> <input type="date" name="Dia" class="form-control <?php echo (!empty($Dia_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Dia; ?>"> <span class="invalid-feedback"><?php echo $Dia_err;?></span> </div> <div class="form-group"> <label>Pagamento</label> <input type="text" name="Pagamento" class="form-control <?php echo (!empty($Pagamento_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Pagamento; ?>"> <span class="invalid-feedback"><?php echo $Pagamento_err;?></span> </div> <div class="form-group"> <label>Codigo do Funcionario</label> <input type="text" name="Funcionario" class="form-control <?php echo (!empty($Funcionario_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Funcionario; ?>"> <span class="invalid-feedback"><?php echo $Funcionario_err;?></span> </div> <input type="submit" class="btn btn-primary" value="Submit"> <a href="home.html" class="btn btn-secondary ml-2">Cancel</a> </form> </div> </div> </div> </div> </body> </html>
Edited May 10 by Barand code tags added I am having trouble setting a checkbox to "checked" if the row "published" is set to "1" (0 being not checked). I know this involves an if published==1 then print "checked", but i just cant get it to work. Any help would be greatly apprecatied: <?php include "base.php"; $sql="SELECT * FROM project"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Id</strong></td> <td align="center"><strong>title</strong></td> <td align="center"><strong>Published</strong></td> <td align="center"><strong>Promoted</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ $pub = $rows['publised']; ?> <tr> <td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td> <td align="center"><? echo $rows['title']; ?></td> <td align="center"><input name="published[]" type="checkbox" id="published" value="<? echo $rows['published']; ?>"></td> <td align="center"><input name="promoted[]" type="text" id="promoted" value="<? echo $rows['promoted']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE project SET published='$published[$i]', promoted='$promoted[$i]' WHERE id='$id[$i]'"; $result1=mysql_query($sql1); } } if($result1){ header("location:update_multiple.php"); } mysql_close(); ?> Hi all, I am not sure if this is possible but I am trying to provide people a link to a page (not mine btw) with values already filled in. So for them it's faster to submit the form. Problem is the Form is using method post. what i tried was the following but it didn't work. there is an input field: Code: [Select] <input type="text" value="" maxlength="255" size="10" id="numpoints" name="numpoints" class="inputbox required">So i thought if I just make an url like : http://godzillaeatsbananas.com/index.php?numpoints=100 it would fill in the field with a value of 100 but it doesn't Anyone might have an idea on how to accomplish this. Thanks! I have developed a form for my website that directs the user to a different site and per-populates the form on the other site with information I want. I would like to take it one step further and make the below script fill out the form on the other site and then submit the form. Currently it just fills out the form on the other site but does not submit it. Is there any way to do this? Code: [Select] <form action="http://www.privatedutyhomecare.org/sections/consumers/locator.php" method="POST"> <input name="state" size="25" type="hidden" value="MI" /> <input name="company" size="25" type="hidden" value="Affordable HomeCare" /> <button type="submit" class="imgpx"> <img src="assets/images/logos/npda.png" alt="submit" width="51" class="nothing" height="40" /> </button> </form> Hello all, looking for some help here as I seem to be fairly stuck... this yields no results at all and I give up, I need help!
The user should be able to select an employee from a select field, and based on their selected we should be able to grab the start time and end time of that empoyee, which resides on the database.
My form:
<form action=".php" name="absence" id="absence" method="post"> Employee: <select name="empid" class="clockinputs" required> <option value=""></option> <option value='20'>Bob Jones</option> <option value='13'>Bob Phones</option> <option value='93'>Bob Lomes</option> <option value='30'>Bob Somes</option> <option value='107'>Bob Pomes</option> <option value='74'>Bob Womes</option> </select> Shift Start: <input type="text" name="startshift" id="startshift" class="clockinputs" data-inputmask="'mask': '99:99:99'" required> Shift End: <input type="text" name="endshift" id="endshift" class="clockinputs" data-inputmask="'mask': '99:99:99'" required> <input type="hidden" name="eid" value="<?php echo $row{'EID'}; ?>"> <input type="submit" value="Save"> </form>Javascript: <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#empid').live('change', function(event) { $.ajax({ url : 'absence-get.php', type : 'POST', dataType: 'json', data : $('#absence').serialize(), success: function( data ) { for(var id in data) { $(id).val( data[id] ); } } }); }); }); </script>And absence-get.php: <?php $e = $_POST['empid']; $result = mysql_query("SELECT * FROM employees WHERE EID='$e' "); $row = mysql_fetch_array($result, MYSQL_ASSOC) $startshift = $row{'startshift'}; $endshift = $row{'endshift'}; $arr = array( 'input#startshift' => $startshift , 'input#endshift' => $endshift ); echo json_encode( $arr ); ?>Anyone spot anything? Thank you! Hello all, I have three text fields ( hosteladmissionnumber,branch & Semester) and three text boxes in a form. When i provide the hostel admission number , the corresponding branch semester must be acquired from the registrationtable in DB and fill it in text boxes. How can i do it? any help would be appreciated. Thanks. I have pasted the code below. [syntax=php] <?php session_start(); $hostad=$_POST['hosteladmissionno']; $sem=$_POST['student_name']; $sem=$_POST['semester']; $con=mysql_connect('localhost','root',''); if(!$con) { die('Unable to connect'.mysql_error()); } mysql_select_db('hostel',$con); //i have to insert the hosteladmission in payment too..but no need to insert semester and branch $r1="INSERT INTO payment(hosteladmissionno) values ('$hostad')"; mysql_close($con); ?> /HTML PART <form action='payment.php' method='POST' name='form1'> <center> <table> <tr><td><b>Admission No:</b></td><td><input type='text' name='hosteladmissionno'></td></tr> <tr><td><b>Student Name:</b></td><td><input type='text' name='student_name'></td></tr> <tr><td><b>Semester:</b></td><td><input type='text' name='semester'></td></tr> [/syntax] This is really blowing my mind... the code is as follows the table, the column names everything is right and contains information but the variables aren't being filled... I don't get it... Anyone have any ideas or options I might not have thought of for debugging? $item_name = ("SELECT * FROM items WHERE id = '$grab_item'"); $que_items = mysql_query($item_name); while ($item_todel = mysql_fetch_array($que_items, MYSQL_BOTH)) { $name = $item_todel['name']; $desc = $item_todel['desc']; } echo ($name . "<br>" . $desc . "<br>" . $grab_item); the only variable thats set is grab_item, fetch_array throws no errors, if I plug in the query straight to the sql I get all the proper information... It's just not filling the two variables.... I am having trouble getting this to work what am I doing wrong? <p class="tenTitle"><p class="tenTitle">Module 4i: Profit / Loss Forecast<br /> <?php // NAME STEP AND GIVE VALUE TO QUESTION VARIABLES SO ERROR CHECKING DOES NOT HAVE TO BE RECREATED FOR EVERY PAGE $stepNumber = '4i'; $numQuestions = '9'; //get values from the $_post array: $totalRev = $_POST['revenue']; echo "totalRev: ".$totalRev."<br />"; $vCost = $_POST['cost']; echo "vCost: ".$vCost."<br />"; $overheadCost = $_POST['overhead']; echo "overheadCost: ".$overheadCost."<br />"; $taxes = $_POST['taxes']; echo "taxes: ".$taxes."<br />"; $otherIncome = $_POST['other']; echo "other: ".$other."<br />"; //Calculate the gross profit: $gross = $totalRev - $vCost; echo "gross: ".$gross."<br />"; //Calculate the net profit: $netProfit = $gross - $overheadCost; echo "netProfit: ".$netProfit."<br />"; // Calculate Income after taxes: $afterTaxes = $netProfit - $taxes; echo "afterTaxes: ".$afterTaxes."<br />"; // Calculate the Total Income: $totalIncome = $afterTaxes + $otherIncome; echo "totalIncome: ".$TotalIncome."<br />"; // Print out the results print ' <table border="1" cellpadding="4" cellspacing="3" width="350"> <tr> <td align="left" valign="top" border="1"> Total Revenue</td><td><input type="text" style="40" name="totalRev" value="'.$totalRev.'"> </td> </tr> <tr> <td align="left" valign="top" border="1"> Less: Variable Cost</td><td><input type="text" style="40" name="vCost" value="'.$vCost.'"> </td> </tr> <tr> <td align="left" valign="top" border="1"> Gross profit</td><td><input type="text" style="40" name="grossProfit" value="'.$GrossProfit.'"> </td> </tr> <tr> <td align="left" valign="top" border="1"> Less: Overhead Cost</td><td> <input type="text" style="40" name="overhead" value="'.$overheadCost.'"> </td> </tr> <tr> <td align="left" valign="top" border="1"> Net Profit</td><td> <input type="text" style="40" name="netProfit" value="'.$netProfit.'"> </td> </tr> <tr> <td align="left" valign="top" border="1"> Taxes</td><td> <input type="text" style="40" name="taxes" value="'.$taxes.'"> </td> </tr> <tr> <td align="left" valign="top" border="1"> Profit After Taxes</td><td> <input type="text" style="40" name="profitAfterTaxes" value="'.$profitAfterTaxes.'"> </td> </tr> <tr> <td align="left" valign="top" border="1"> Other Income</td><td> <input type="text" style="40" name="otherIncome" value="'.$otherIncome.'"> </td> </tr> <tr> <td align="left" valign="top" border="1"> Net Income</td><td> <input type="text" style="40" name="netIncome" value="'.$netIncome.'"> </td> </tr> <tr> <td colspan="2" align="left" valign="top" border="1"> <input type="submit" name="submit" id="Submit" value="Calculate" /> </label></td> </tr> </table></form>'; // DEFINE SESSION VARIABLES $_SESSION['email']=$_POST['email']; $_SESSION['emailCc']=$_POST['emailCc']; $_SESSION['name']=$_POST['name']; // DEFINE VARIABLES FOR MAILING TO USER AND BUZGATE $to = 'askbuz@buzgate.org,'.$_POST['email']; $email_subject = "Step ".$stepNumber." in Buzgate's Five Step Program"; for ($i = 1; $i <= $numQuestions; $i++) { $eBodyQuestions .= $questions[$i]."\n" .$_POST['data'.$i]."\n"; } $email_body = $eBodyQuestions; $headers = "From:".$_POST['email']; //PLACE VARIABLES IN MAIL FUNCTION mail($to, $email_subject, $email_body, $headers); // DEFINE VARIABLES FOR MAILING TO USER AND BUZGATE $toCc = $_POST['emailCc']; $email_subjectCc = "Step ".$stepNumber." in Buzgate's Five Step Program from ".$_POST['name']; $email_bodyCc = $_POST['name']." has sent this to you from www.BUZGate.org/8.0/".$state_abbrv_low."/".$page_name."\n Please contact us at askbuz@buzgate.org if you have received this in error.\n"; $email_bodyCc = $email_bodyCc.$eBodyQuestions; $headersCc = "From:askbuz@buzgate.org"; //PLACE VARIABLES IN CC MAIL FUNCTION mail($toCc, $email_subjectCc, $email_bodyCc, $headersCc); // DISPLAY RESPONSE TO CORRECTLY FILLING OUT FORM echo "<p class='textCenter'>Thank you ".$_POST['name']." for completing Step ".$stepNumber."</p> <p class='textCenter'><a href='five_steps_4summary.html'>Click here</a> to continue to 4Summary</p> <p class='textCenter'>Or <a href='five_steps_".$stepNumber.".html'>try this form again</a>.</p>"; ?> In my login form I'm getting the error Code: [Select] Notice: Use of undefined constant Errors - assumed 'Errors' in /home/content/n/a/t/nathanwatson/html/admin/YBK/post.php on line 91 Warning: Cannot modify header information - headers already sent by (output started at /home/content/n/a/t/nathanwatson/html/admin/YBK/post.php:91) in /home/content/n/a/t/nathanwatson/html/admin/YBK/post.php on line 91 Warning: Cannot modify header information - headers already sent by (output started at /home/content/n/a/t/nathanwatson/html/admin/YBK/post.php:91) in /home/content/n/a/t/nathanwatson/html/admin/YBK/post.php on line 92 //if the name exists it gives an error if ($check2 != 0) { //Line 85 $error="<span style="; $error .="color:red"; $error .=">"; $error .= "Sorry, the username is already in use."; $error .="</span>"; setcookie(Errors, $error, time()+20); //Line 91 header('Location: /YBK/'); //Line 92 exit; } Hi Guys, Can someone please tell me why no echo statements work after my heredoc :? Here's the code: Code: [Select] <?php switch($_POST['options']){ case '1': $selected1 = 'selected'; break; case '2': $selected2 = 'selected'; break; case '3': $selected3 = 'selected'; break; case '4': $selected4 = 'selected'; break; default: $selected1 = $selected2 = $selected3 = $selected4 = ''; } echo <<<END <html> <head> <script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } function formSubmit() { document.getElementById("frm1").submit(); } </script> </head> <body> <form id="frm1" method="post" action="search.php" /> <select onclick="formSubmit()" name="options" size="1"> <option $selected1 value="1">date</option> <option $selected2 value="2">year</option> <option $selected3 value="3">country</option> <option $selected4 value="4">language</option> </ select> </body> </html> </form> END; if(isset($_POST['options'])){ echo "item chosen"; } It works when I put the 'isset' if clause before the heredoc and even weirder, if i add a submit input type in the form as the last field it works as is? ex: Code: [Select] <?php switch($_POST['options']){ case '1': $selected1 = 'selected'; break; case '2': $selected2 = 'selected'; break; case '3': $selected3 = 'selected'; break; case '4': $selected4 = 'selected'; break; default: $selected1 = $selected2 = $selected3 = $selected4 = ''; } echo <<<END <html> <head> <script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } function formSubmit() { document.getElementById("frm1").submit(); } </script> </head> <body> <form id="frm1" method="post" action="search.php" /> <select onclick="formSubmit()" name="options" size="1"> <option $selected1 value="1">date</option> <option $selected2 value="2">year</option> <option $selected3 value="3">country</option> <option $selected4 value="4">language</option> <input type="submit"> </ select> </body> </html> </form> END; if(isset($_POST['options'])){ echo "item chosen"; } Any help would be greatly appreciated! Cheers D when i click submit the form isnt sending to the dataabse...any help really appreciated!! heres the code: Code: [Select] <?php session_start(); $errorMsg = ""; if (isset($_POST['billing'])){ include_once "connect_to_mysql.php"; $firstname = preg_replace("[^A-Za-z0-9]", "", $_POST['firstname']); $lastname = preg_replace("[^A-Z a-z0-9]", "", $_POST['Last Name']); $address = preg_replace("[^A-Z a-z0-9]", "", $_POST['address']); $phone = preg_replace("[^A-Z a-z0-9]", "", $_POST['phone']); $creditcard = preg_replace("[^A-Z a-z0-9]", "", $_POST['creditcard']); $expiry = preg_replace("[^A-Z a-z0-9]", "", $_POST['expiry']); $CVV = preg_replace("[^A-Z a-z0-9]", "", $_POST['CVV']); $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); if((!$firstname) || (!$lastname) || (!$address) || (!$phone) || (!$creditcard) || (!$expiry) || (!$CVV) || (!$email)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$firstname){ $errorMsg .= "--- First Name"; } else if(!$lastname){ $errorMsg .= "--- Last Name"; } else if(!$address){ $errorMsg .= "--- Address"; } else if(!$phone){ $errorMsg .= "--- Phone"; } else if(!$creditcard){ $errorMsg .= "--- Credit Card"; } else if(!$expiry){ $errorMsg .= "--- Expiry"; } else if(!$CVV){ $errorMsg .= "--- CVV"; } else if(!$email){ $errorMsg .= "--- Email Address"; } } else { $id = mysql_insert_id(); $sql = mysql_query("INSERT INTO customer (firstname, lastname, address, phone, creditcard, expiry, CVV, email) VALUES('$firstname','$lastname','$address','$phone','$creditcard','$expiry','$CVV','$email' now())") or die (mysql_error()); print "<br /><br /><br /><h4>OK $firstname, Thanks for Shopping:</h4><br /> We just sent a Confirmation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox. Thank You.</font></strong><br />"; exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Billing</title> <link href="../dnb2.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include_once("../template_header2.php");?> <table width="600" align="center"> <tr> <td width="7%" align= "center">Billing</td> </tr> </table> <table width="600" align="center" cellpadding="5"> <form action="billing.php" method="post" enctype="multipart/form-data"> <tr> <td colspan="2"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> </tr> <tr> <td width="163"><div align="right">First Name:</div></td> <td width="409"><input name="firstname" type="text" value="<?php echo "$firstname"; ?>" /></td> </tr> <tr> <td width="163"><div align="right">Last Name:</div></td> <td width="409"><input name="lastname" type="text" value="<?php echo "$lastname"; ?>" /></td> </tr> <tr> <td width="163"><div align="right">Address:</div></td> <td width="409"><input name="address" type="text" value="<?php echo "$address"; ?>" /></td> </tr> <tr> <tr> <td width="163"><div align="right">Phone:</div></td> <td width="409"><input name="phone" type="text" value="<?php echo "$phone"; ?>" /></td> </tr> <tr> <td><div align="right">Credit Card: </div></td> <td><input name="creditcard" type="text" value="<?php echo "$creditcard"; ?>" /></td> </tr> <tr> <td><div align="right">Expiry: </div></td> <td> <input name="expiry" type="text" value="<?php echo "$expiry"; ?>" /> </td> </tr> <tr> <td width="163"><div align="right">CVV:</div></td> <td width="409"><input name="CVV" type="text" value="<?php echo "$CVV"; ?>" /></td> </tr> <tr> <td><div align="right">Email: </div></td> <td><input name="email" type="text" value="<?php echo "$email"; ?>" /></td> </tr> <tr> <td><div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> </table> </body> </html> I want to submit data of my student registration form to the database. If an admission number already exists, a message should be displayed like this. "Admission number2012/1..This student has been already entered to the system." I have created the below coding which fulfill the above task. But i want slight modification, rather than displaying the message in a seperate field after entering all the fields i want the message to display soon after entering the "Admission Number" in my form. newStudentRegistrationFormValidation.php Code: [Select] <?php $admission_no=$_POST['admission_no']; $admission_date=$_POST['admission_date']; $full_name=$_POST['full_name']; $name_with_initial=$_POST['name_with_initial']; $date_of_birth=$_POST['date_of_birth']; $religion=$_POST['religion']; //$gender=$_POST['gender']; $address=$_POST['address']; $telephone=$_POST['telephone']; $grade_on_admission=$_POST['grade_on_admission']; $grade_ID=$_POST['grade_ID']; $stream_ID=isset($_POST['stream_ID']); $class_ID=$_POST['class_ID']; $student_house=$_POST['student_house']; $password=$_POST['password']; $description_about_st=$_POST['description_about_st']; $payment=$_POST["payment"]; $currentdate=getdate(time()); $year=$currentdate["year"]; //admission number validation $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); $query="SELECT admission_no FROM student_info Where student_info.admission_no='$admission_no'"; $result=mysql_query($query) ; $num_rows = mysql_num_rows($result); echo $num_rows; if($num_rows >= 0) { header("location:student registrationDatabase.php?admission_no=".urlencode($admission_no)."&year=".urlencode($year)."&admission_date=".urlencode($admission_date)."&full_name=".urlencode($full_name)."&name_with_initial=".urlencode($name_with_initial)."&date_of_birth=".urlencode($date_of_birth)."&religion=".urlencode($religion)."&address=".urlencode($address)."&telephone=".urlencode($telephone)."&grade_on_admission=".urlencode($grade_on_admission)."&grade_ID=".urlencode($grade_ID)."&stream_ID=".urlencode($stream_ID)."&class_ID=".urlencode($class_ID)."&student_house=".urlencode($student_house)."&password=".urlencode($password)."&description_about_st=".urlencode($description_about_st)."&payment=".urlencode($payment)); exit(); }else{ ?> <body> <?php echo "Admission number".$admission_no." .This student has been already entered to the system ."."<BR>"."<BR>"."<BR>"; echo "<a href='newStudentRegistrationForm.php'>GO to manage student details page</a> "; exit(); }?> </body> </html> I am stuck on trying to get the form to repopulate after a failed validation. The real form involves REST calls and such but I trimmed the code back to this issue. I think I need to declare the variables differently. I also tried to use the variables in the PHP script to refill the form with the original form entries. I have tried numerous ways of getting the variables to repopulate but could never get it to work consistently (such as declaring global variables. Here is the form code: Code: [Select] <div> <a name="error_field"></a> <?php if($_GET['error']): ?> <div style="padding:10px;border:1px solid;color:#C70C0C;"><?php echo $_GET['error'] ?></div> <?php endif; ?> <div> <form method="post" action="process2.php"> <fieldset name="Group1"> <legend>Account Registration</legend> <div id="field"><label id="Firstname">First Name:</label></div> <div id="input"><input name="Firstname" id="Firstname" type="text" value="<?php $_POST['Firstname']?>"/></div> <div id="field"><label id="Lastname">Last Name:</label></div> <div id="input"><input name="Lastname" id="Lastname" type="text" value="<?php $_POST['Lastname']?>"/></div> <div id="field"><label id="Username">E-Mail Username):</label></div> <div id="input"><input name="Username" type="text" value="<?= $_POST['Username']?>"/></div> <div id="field"><label id="Password">Password:</label></div> <div id="input"><input name="Password" type="password" /></div> <div class="center" style="margin-top:15px;margin-bottom:15px"> <input name="Submitx" type="submit" value="submit" /> <input name="Reset1" type="reset" value="reset" /> </div> </fieldset></form> </div> </div> and here is the PHP which I have on a different page Code: [Select] <?php $new_user_username = check_input($_POST['Username'], "Enter your e-mail"); $new_user_password = check_input($_POST['Password'], "Enter your password"); $new_user_first_name = check_input($_POST['Firstname'], "Enter your first name"); $new_user_last_name = check_input($_POST['Lastname'], "Enter your last name"); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $new_user_username)) { show_error("E-mail address not valid"); } else{ header('Location: TY.php'); } function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { header('Location: tp1.php?error=' . $myError); exit(); } ?> Thanks in advance for any help. Hi folks, I have had a developer code a site with the following payment methods: Authorize.net (AIM), Paypal Web Payments Pro, and Cash only. When I submit my payment form with any of the above processors, the page refreshes and deletes all the information recorded. Nothing is submitted through the APIs, recorded in the admin panel of the site or emailed. However, my developer from the Ukraine is able to use the form perfectly. We have tried it on several different computers in the US and none of them work. He and his fellow coders are able to submit information using the forms without a problem and are suggesting that something is wrong on my end. Neither one of us can figure out what the problem is because nothing shows up in the PHP error dumps. Any thoughts? I'm putting my money on Javascript, but I'm not sure. I will post the site if necessary, just request it. |