PHP - Moved: How To Make A Save To Html Form
This topic has been moved to HTML Help.
http://www.phpfreaks.com/forums/index.php?topic=348155.0 Similar TutorialsHello folks I am new to php and I have been trying to put together a database that a user can search and choose from the results. I have managed to make this script by copying code from google searches and trial and error. The script so far has been tested and works. The hard part is the code for choosing from the results, I have tried some things but I have been far from the mark, the thing is I can't get my head around the problem, if the first field is a number which is unique to each row, how can I pick that up in a php argument. I have tried making the first field an href link to send that number to a different table which would collect the results of the users choices, but I'm just not sure what to put in the code. Could someone throw me a lifeline here I've searched for hours on google to find any code that looks like it would work with no luck. // Get the search variable from URL $var = @$_GET['a'] ; $trimmed1 = trim($var); //trim whitespace from the stored variable $var = @$_GET['b'] ; $trimmed2 = trim($var); $var = @$_GET['c'] ; $trimmed3 = trim($var); $var = @$_GET['d'] ; $trimmed4 = trim($var); $var = @$_GET['e'] ; $trimmed5 = trim($var); $var = @$_GET['f'] ; $trimmed6 = trim($var); //connect to your database mysql_connect("localhost","root",""); //(host, username, password) //specify database mysql_select_db("a2149809_MV") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "SELECT * FROM `table` WHERE `field1` LIKE \"%$trimmed1%\" AND `field2` LIKE \"%$trimmed2%\" AND `field3` LIKE \"%$trimmed3%\" AND `field4` LIKE \"%$trimmed4%\" AND `field5` LIKE \"%$trimmed5%\" AND `field6` LIKE \"%$trimmed6%\" order by `field1`"; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); <table width="100%" border=2 cellspacing=2 cellpadding=2> <tr><form name="form" action="" method="get"> <td colspan="6"><input type="submit" name="Submit" value="Search" /> </td> </tr> <tr> <td><input type="text" name="a" value="" size="4" /></td> <td><input type="text" name="b" value="" size="40" /></td> <td><input type="text" name="c" value="" size="3" /></td> <td><input type="text" name="d" value="" size="10" /></td> <td><input type="text" name="e" value="" size="10" /></td> <td><input type="text" name="f" value="" size="10" /></td> </form></tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"Field1"); $f2=mysql_result($result,$i,"Field2"); $f3=mysql_result($result,$i,"Field3"); $f4=mysql_result($result,$i,"Field4"); $f5=mysql_result($result,$i,"Field5"); $f6=mysql_result($result,$i,"Field6"); ?> <tr> <td><?php echo $f1; ?></td> <td><?php echo $f2; ?></td> <td><?php echo $f3; ?></td> <td><?php echo $f4; ?></td> <td><?php echo $f5; ?></td> <td><?php echo $f6; ?></td> </tr> <?php $i++; } ?> </table> How to make a form using HTML/PHP with conditional responses based on zip code? What I want to do exactly... zip codes 91900-92600 go to URL www.example.com after submit. All others go to URL www.example.com/page after submit. Any help would be much appreciated. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=343133.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=353684.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=317537.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=331164.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=321638.0 I have html form and verify post data via pgp how can I save someone data if some one fill incorrect information
Hi All, $userClient = "VARIABLE OF WHO IS LOGGED IN"; <form action="actions/assign.php" method="post"> <?php $sql = "SELECT * FROM Engineers where Engineer_Company = '".addslashes($userClient)."' and userType = '5'"; $result = mysqli_query($db, $sql); while($row = mysqli_fetch_assoc($result)) { $userSID = $row["userID"]; echo '<tr> <td>'.$row["userName"].' <input type="hidden" class="form-control" id="usersID[]" name="usersID'.$row["userID"].'" value="'.$row["userID"].'"> <input type="hidden" class="form-control" id="date" name="date" value="'.date('d-m-Y').'"> </td> <td>'; $sql1 = "SELECT * FROM job_orders where companyID = '".addslashes($userClient)."'"; $result1 = mysqli_query($db, $sql1); echo "<select style='width: 250px;' id='job$userSID' name='job$userSID'>"; echo '<option value="">-- Please Select --</option>'; while($row1 = mysqli_fetch_assoc($result1)) { echo '<option value="'.$row1["jobID"].'">'.$row1["jobtitle"].'</option>'; } echo "</select>"; echo '</td> <td>'; $query = $db->query("SELECT * FROM Engineer_Company WHERE Company_ID = '".addslashes($userClient)."'"); $rowCount = $query->num_rows; if($rowCount > 0){ echo ' <select name="company'.$userSID.'" id="company'.$userSID.'" style="width: 250px;"> <option value="">-- Select Company --</option>'; while($row = $query->fetch_assoc()){ echo '<option value="'.$row['Engineer_Company_ID'].'" class="form-control form-control-sm">'.$row['Engineer_Company_Name'].'</option>'; } echo '</select>'; } echo'</td> <td> <div class="form-group"> <select id="site'.$userSID.'" name="site'.$userSID.'" style="width: 250px;"> <option value="">-- Select Site --</option> </select> </div> '; echo'</td> </tr>'; echo ' <script type="text/javascript"> $(document).ready(function(){ $("#company'.$userSID.'").on("change",function(){ var diag_id = $(this).val(); if(diag_id){ $.ajax({ type:"POST", url:"ajax-client-side.php", data:"diag_id="+diag_id, success:function(html){ $("#site'.$userSID.'").html(html); } }); } }); }); </script>'; } ?> </tbody> </table> <input class="btn btn-dark float-right" type="submit" value="Allocate"> </form>
Well, folks, thanks to all the help, I've narrowed my problem down to needing a way to allow a variable value to traverse into subsequent calls of a function. I have a simple integer - "companyID", and it's set in "actionfile.php" which is called by two forms. The first time it's called by Form A, it's set. I'd LIKE to put it into $_SESSION, but apparently $_SESSION is zeroed out before I can use it in the second call to "actionfile.php" by Form B. A new form/function call is a new session? I've tried setting it to global and static, to no avail. Anything more elegant than writing the value to SQL for later retrieval? Thanks! Mark I found this site: http://www.wallpaperama.com/forums/how-to-save-html-output-code-from-php-script-t6898.html it demonstrates how to save html output code from php script. here is an example: http://ads4agents.com/date.php I cant get it to work on my site...where is the correct place ad these: ob_start(); $HtmlCode= ob_get_contents(); ob_end_flush(); How can I get this to work in my php? view_ad.php <html> <body> <center> <br/> <h1>Apartment Reference #: <?php echo $_POST["reference"]; ?><br /></h1> <br/> <?php echo $_POST["application"]; ?>, <?php echo $_POST["deposit"]; ?><br /> <?php echo $_POST["pets"]; ?><br /> <br/> <?php echo $_POST["community"]; ?><br /> <?php echo $_POST["interior"]; ?><br /> <?php echo $_POST["amenities"]; ?><br /> <br/> <?php echo $_POST["contact"]; ?><br /> <a href="<?php echo $_POST['website'] ?>"><?php echo $_POST['website'];?></a><br/> <br/> <br/> <br/> </body> </html> Hey guys! I have the following script to create an excel file, the thing is that I dont want to be asked if I want to open or save the file when accessing the php file...I just want the php file directly to save the excel file. Heres the code: $filename = "test.xls"; $contents = "testdata1 \ntestdata2 \ntestdata3 \n"; header('Content-type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename='.$filename); echo $contents; Is there a way instead of using the header function, use something like: fopen, fwrite, fclose ? Thanks in advance! Cheers, I have a form which a user enters information like age, email, address. This information is emiled to the admin. I would like the information to also be saved to a textfile on the server when the same button is pressed Please help Thank you in advance, for your time and effort Greetings! I'm new in phpmysql. Am making signup form with three users (Admin, office and student), that when student is selected there will be another form that need to fill up and the data is saved in different table. Below are my codes when the data of admin and office are submitted. Code: [Select] mysql_query("INSERT INTO tbl_user (user_Id,user_Password,user_Fname,user_Lname,user_Sex,user_Level,user_Program) VALUES ('$userid','$password','$fname','$lname','$sex','$level','$program')"); these things here are codes for student when submitted Code: [Select] mysql_query("INSERT tbl_studenroll (user_Id, course_Id, ap_Id, se_Sem, se_Yearlevel) VALUES ('$userid','$course', '$acadyear', '$sem', '$year')") or die(mysql_error()); $seID = mysql_query ("SELECT max(se_Id) AS mxSEid FROM tbl_studenroll")or die (mysql_error()); $seID1 = mysql_fetch_assoc($seID); $seID = $seID1['mxSEid']; $offcourse = mysql_query("SELECT office_Id FROM tbl_offcourse WHERE course_Id = '$course'")or die (mysql_error()); while ($row = mysql_fetch_array($offcourse)) { $off = $row['office_Id']; mysql_query("INSERT tbl_data (se_Id,office_Id,user_Id,course_Id) VALUES ('$seID','$off','$userID','$courseID')") or die(mysql_error()); } sEE that I am saving in three tables at the same time when student is selected. How can I do it? I want to save only what for students and for other users..I tried my codes but when I submit data from office, it saves data to studenroll, but in 0 value. hope I am clear, help me guys! thank you in advace. Hi, I have made a basic html site and it has two forms on it. I have the forms linking to a file called process.php. Basically i need to know what code to put in the php file in order for the forms to save whatever is entered in them to a txt file on my server or computer. Or any other easier way to do the same thing, save the content of two forms on my site. Hope i posted this in the right forum subject. Thanks very much for anyone that helps. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=315050.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=307669.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=316783.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=310894.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=347193.0 |