Search the Community
Showing results for tags 'html form'.
-
Hello everyone! For a home project I have to create a database and a table inside. Then let users insert data into table via simple html form. This form uses a php file to do the inserting, the form is just to get data. I'm using MyphpAdmin in wampserver to create database and table manually. here is my code: in the first file for connecting to server and selecting database <?php $server="localhost"; $user= "root"; $password=""; $connect=@MySQL_Connect($server,$user,$password) or die ("connection failed!"); echo "Server Access granted"; $base= "Mabase"; MySQL_Select_db($base); echo "<br>Mabase was selected" ?> =================== the second file is a simple html form =================== <html> <head> <title>Formulaire de Saisie</title> </head> <body> <form action = "traiter.php" method = "POST"> Enter Code : <input type = "text" name = "Code"></input><br> Enter Designation : <input type = "text" name = "Des"></input><br> Entrez Prix Unitaire : <input type = "text" name = "PU"></input><br> Entrez Quantite en stock : <input type = "text" name = "QS"></input><br> <input type = "submit" value = "valider"> </form> </body> </html> ==================== the third file is traiter.php that you see in the html form ==================== <?php require ("choixBD.php"); $code = $_POST["Code"]; // product code $des = $_POST["Des"]; // meaning $pu = $_POST["PU"]; // unie price $qs = $_POST["QS"]; // quantity $pttc = $pu*1.2; // TAX $nomtable = "Produit"; $req = "INSERT INTO $nomtable (Code,Designation,Quantite,PrixUnitaire,PTTC) VALUES('$code','$des,'$qs','$pu','$pttc')"; $result = @MySQL_Query($req); if (!$result) { echo "<br> impossible to execute ($req) in db".@MySQL_error(); exit; } echo"<br>Values have been added"; ?> ===================== the idea is that the user will open the form file and enter data and click submit and data should be added the problem is that data are not added and I don't know why. here is the error message impossible to execute (INSERT INTO Produit (Code,Designation,Quantite,PrixUnitaire,PTTC) VALUES('s425','gaming mouses,'190','1300','1560')) in dbYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '190','1300','1560')' at line 1 Thanks in advance
-
Hi! I'm hoping someone can help me out with a HTML form using PHP. The form allows users to upload a file (and that part works) but it's supposed to attach that file in the email it sends with the form info. I've looked and looked and looked but I haven't been able to find a resolution. HELP!!! <?php $fileName = $_FILES["fileatt"]["name"]; // The file name $fileTmpLoc = $_FILES["fileatt"]["tmp_name"]; // File in the PHP tmp folder $fileType = $_FILES["fileatt"]["type"]; // The type of file it is $fileSize = $_FILES["fileatt"]["size"]; // File size in bytes $fileErrorMsg = $_FILES["fileatt"]["error"]; // 0 for false... and 1 for true move_uploaded_file($fileTmpLoc, "uploads/$fileName"); if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); } $data = chunk_split(base64_encode($data)); $From = $_POST['From']; $Email = $_POST['Email']; $Campaign = $_POST['Campaign']; $Subject = $_POST['Subject']; $email_sub = "Email request confirmation"; $datepicker = $_POST['datepicker']; $Specialty = implode(', ', empty($_POST['Specialty']) ? array() : $_POST['Specialty'] ); $Template = $_POST['Template']; $url = 'http://lwwjournals.com/#calendar'; $Notes = $_POST['Notes']; $formcontent=" New Email Request from $Name \n \n --------------------------------------- \n \n From: $From \n Email: $Email \n Campaign: $Campaign \n Subject: $Subject \n Date: $datepicker \n Specialty: $Specialty \n Template: $Template \n Uploaded File: $fileName \n Notes: $Notes $data"; $formcontent2=" Hey there! Thanks for submitting your request, here's a copy of the information you submitted. \n \n --------------------------------------- \n \n From: $From \n Email: $Email \n Campaign: $Campaign \n Subject: $Subject \n Date: $datepicker \n Specialty: $Specialty \n Uploaded File: $fileName \n Template: $Template \n Notes: $Notes"; $recipient = "email@dummyemail.com"; $subject = "2013 Email Request"; mail($recipient, $subject, $formcontent,'From: emails@lwwjournals.com','-f emails@lwwjournals.com' ) or die("Error!"); mail($Email, $email_sub, $formcontent2,'From: emails@lwwjournals.com','-f emails@lwwjournals.com' ) or die("Error!"); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> index.html mail.php
-
I have a html form which is spread over two pages. What is the best way to collect information from the two pages and insert them into a single mysql database? Do I carry the results from the first form over to client_start_2.html and then process the the parts of the form together? Or is best to process the halves of the form seperately somehow? <div id="clientform"> <p>Please enter your details below, and 3 of your local tree surgeons will get in touch! or <a href="login.html">login</a><br /><br/></p> <form action="client_start_2.html" method="post"> <p class="left"><label for="name" class="required">Your Name</label><br> <input class="field required" id="name" name="name" placeholder="Your Name" required tabindex="1" type="text" ></p> <p class="right"><label for="email" class="required">Your Email Address</label><br> <input class="field required" id="email" name="email" placeholder="Your Email Address" required tabindex="1" type="email"></p> <div style="clear:both" /> <p class="left"><label for="phone">Your Phone Number</label><br> <input class="field" id="phone" name="phone" placeholder="Your Phone Number" tabindex="3" type="text"></p> <p class="right"><label for="postcode">Your Full Postcode</label><br> <input class="field" id="postcode" name="postcode" placeholder="Your Full Postcode" tabindex="4" type="text"></p> <div style="clear:both" /> <p class="left"><label for="type" class="required">Type of works</label><br> <select class="dropdown required" id="type" name="type" required="required" tabindex="9"> <option value=""> Please Select </option> <option value="1">Tree Surgery</option> <option value="2">Stump Grinding</option> <option value="3">Tree Surgery and Stump Grinding</option> </select></p> <p class="right"><label for="phone">Ideal Start Date</label><br> <input class="field" id="phone" name="phone" placeholder="Your Phone Number" tabindex="5" type="text"></p> <div style="clear:both"> <p class="left"><label for="question" class="required">Brief Description of Works</label><br> <textarea class="textarea required" id="question" name="question" placeholder="Your Question" required tabindex="10"></textarea></p> <p class="button"><button tabindex="6" type="submit">Submit</button></p> <div style="clear:both" /> </form> and then on client_start_2.html; <div id="clientform"> <p>Nearly there... Please choose a username and password, then were all done! <br/><br/></p> <form action="my-processing-page.php" method="post"> <p><label for="name" class="required">Username</label><br> <input class="field required" id="name" name="name" placeholder="Your Name" required tabindex="1" type="text" ></p> <div style="clear:both" /> <p class="left"><label for="password" class="required">Password</label><br> <input class="field required" id="password" name="password" placeholder="password" required tabindex="2" type="text"></p> <p class="right"><label for="confirm">Confirm Password</label><br> <input class="field" id="confirm" name="confirm" placeholder="confirm password" tabindex="3" type="text"></p> <div style="clear:both" /> <p class="left">Do you agree to the terms and conditions? <br/><input type="radio" value="Yes" name="Yes" > Yes <input type="radio" value="No" name="No"> No </p> <p class="button"><button tabindex="6" type="submit">Submit</button></p> <div style="clear:both" /> </form> Many thanks
-
Hi there ! What i'm traying to do is to get latitude and longitude form imputed postcodes. Which works fine as long as i stick to only one input (first or second seperate). I can't get it to work once i try with both of them. i'm using onchange event .. Please ake a look at the form: <form name="latlon" action="test2a.php" method='post' onchange="return usePointFromPostcode(document.getElementById('postcode').value) && usePointFromPostcode1(document.getElementById('postcode1').value) "> <input id="postcode" type="text" size="10" /><br> <input id="postcode1" type="text" size="10"/><br> Latitude:<input name="lat" type="text" id="lat" size="10"/><br /> Longitude:<input name="lon" type="text" id="lon" size="10"/><br><br> Latitude:<input name="lat1" type="text" id="lat1" size="10"/><br /> Longitude:<input name="lon1" type="text" id="lon1" size="10"/> <input type="submit" value="Get Lat / Lon"/> </form> and a Java Script used to get latitude and longitude: function usePointFromPostcode(postcode, callbackFunction) { localSearch.setSearchCompleteCallback(null, function() { if (localSearch.results[0]) { var resultLat = localSearch.results[0].lat; var resultLng = localSearch.results[0].lng; var point = new GLatLng(resultLat,resultLng); document.forms['latlon'].lat.value=resultLat; document.forms['latlon'].lon.value=resultLng; callbackFunction(point); }else{ alert("Postcode not found!"); } }); localSearch.execute(postcode + ", UK"); } function usePointFromPostcode1(postcode1, callbackFunction) { localSearch.setSearchCompleteCallback(null, function() { if (localSearch.results[0]) { var resultLat = localSearch.results[0].lat; var resultLng = localSearch.results[0].lng; var point = new GLatLng(resultLat,resultLng); document.forms['latlon'].lat1.value=resultLat; document.forms['latlon'].lon1.value=resultLng; callbackFunction(point); }else{ alert("Postcode not found!"); } }); localSearch.execute(postcode1 + ", UK"); } I'm totaly stuck here. What do i do wrong? Will appreciate any help and thank you in advance.
-
Here is a row from my merchandise table: <tr> <td>Product ID</td> <td>Artist</td> <td>Title</td> <td>Album Art</td> <td>Label</td> <td>Year</td> <td>Price</td> <td> <input type='text' name='cart[dawn of chaos][]' value='0' size='2'/> </td> </tr> I would like to direct your attention to the input row. In my PHP, the input field actually says "name=cart[$title][]" etc... Then I would like to reference the multidimensional array with PHP. To begin I just added a simple foreach. foreach($_POST['cart'] as $item){ echo $item; } PHP says this: Array ( ) Notice: Undefined index: cart in /you/probably/don't/need/my/filepath/cart.php on line 6 Warning: Invalid argument supplied for foreach() in....