PHP - Posting Submitted Text Data To A New Page
Hello. I currently have a web page that allows a user to enter text into a form then select a "Submit Query" button; upon doing this the entered text is saved to a database and displayed for the user on the same page (the page where the form and "Submit Query" button are located).
My question is as follows: I wish the results to be displayed on a new page when the "Submit Query" button is clicked, not displayed on the same page. Is this achieved through targeting? I am a bit lost at this point on how to achieve this result. Thank-you in advance for any help. ~Matty Similar TutorialsI ve been having trouble processing form data to the same page as the do on facebook comments. Can php scripts do that. Help me guys!! Hello, Basically, What I'm looking for would be for a method of blocking certain email addresses from being submitted in a form, I need it to block certain emails that are on the list. I think the best way to describe it would be a form submission blacklist that is checked before it gets submitted. Many thanks I have been using an inventory application built on PHP/MySQL. Since this morning I could submit the data and they were perfectly reflected on the MySQL Table. However, for a few hours I cannot save the submitted data to the table and it doesn't show any error message. Please note no change have been made since it was successfully running. The developer of this application is not available right now.
PLEASR HELP I AM A NOVICE IN PHP/MYSQL.
<?php $GLOBALS['title']="Admission-HMS"; $base_url="http://localhost/hms/"; require('./../../inc/sessionManager.php'); require('./../../inc/dbPlayer.php'); require('./../../inc/fileUploader.php'); require('./../../inc/handyCam.php'); $ses = new \sessionManager\sessionManager(); $ses->start(); if($ses->isExpired()) { header( 'Location:'.$base_url.'login.php'); } else { $name=$ses->Get("loginId"); } $msg=""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST["btnSave"])) { $db = new \dbPlayer\dbPlayer(); $msg = $db->open(); echo '<script type="text/javascript"> alert("'.$msg.'");</script>'; if ($msg = "true") { $userIds = $db->getAutoId("U"); $flup = new fileUploader\fileUploader(); $perPhoto = $flup->upload("/hms/files/photos/",$_FILES['perPhoto'], $userIds[1]); // var_dump($perPhoto); $handyCam=new \handyCam\handyCam(); if (strpos($perPhoto, 'Error:') === false) { $dateNow=date("Y-m-d"); $data = array( 'userId' => $userIds[1], 'userGroupId' => "UG004", 'name' => $_POST['name'], 'studentId' => $_POST['stdId'], 'cellNo' => $_POST['cellNo'], 'gender' => $_POST['gender'], 'dob' => $handyCam->parseAppDate($_POST['dob']), 'passportNo' => $_POST['passportNo'], 'fatherName' => $_POST['fatherName'], 'fatherCellNo' => $_POST['fatherCellNo'], 'perPhoto' => $perPhoto, 'admitDate' => $dateNow, 'isActive' => 'Y' ); $result = $db->insertData("studentinfo",$data); if($result>=0) { $data = array( 'userId' => $userIds[1], 'userGroupId' => "UG004", 'name' => $_POST['name'], 'loginId' => $_POST['stdId'], 'verifyCode' => "vhms2115", 'expireDate' => "2115-01-4", 'isVerifed' => 'Y' ); $result=$db->insertData("users",$data); if($result>0) { $id =intval($userIds[0])+1; $query="UPDATE auto_id set number=".$id." where prefix='U';"; $result=$db->update($query); // $db->close(); echo '<script type="text/javascript"> alert("Admitted Successfully.");</script>'; } else { echo '<script type="text/javascript"> alert("' . $result . '");</script>'; } } elseif(strpos($result,'Duplicate') !== false) { echo '<script type="text/javascript"> alert("Student Already Exits!");</script>'; } else { echo '<script type="text/javascript"> alert("' . $result . '");</script>'; } } else { echo '<script type="text/javascript"> alert("' . $perPhoto . '");</script>'; } } else { echo '<script type="text/javascript"> alert("' . $msg . '");</script>'; } } I'd like to edit specific parts of a submitted text what is the best way to do this? For example I get the following text: [name country] is very cold this time of year. Because I like the cold I would love to live there [end of line 2] whole lot more text here until [name country] if this text here exists, blabla [but Germany] is blabla [end of line] in some cases some more text here [summary] bla bla The text in the brackets are words that I already know before it has been submitted. Getting the words out has been part of my previous script, using preg_match and put them in variables. I want to put the first portion of the text in a row, if 2nd, 3rd and 4th portion exist, put them in a row too. Any ideas? [edited] I prefer to have these portions cut out and put in a variable. So I end up having a few variables and can later echo that out in rows Edited by dde, 18 January 2015 - 04:01 AM. Hi, I am working on a registration login system and after a person registers and logs in, they will get the option to upload a profile picture. The picture and registration info will need to be in two different tables. I want to know the best way to associate the two (registration info and photo) so that I know who's picture goes with what registration info? I thought about IP address, but a user might register on one computer and login and upload a photo on another computer. Hello! I have a 2 questions: Q1: How do you store answers from a php file(see code below) into another file?(php preferably) I know it would probably be easier using a database, but I would like to know how to do it with a text/php file. Below you can see a piece of code for a page students would go on to fill in online exercices. They would first have to input their names. These names would have to be sent to a php file called "StudentAnswers.php". As well as their answers I also have another file that is called "QandA.php" which is called on with include in the piece of code below so the students can't see the answers before they submitted their answers. Q2: But how do I complete the if code(see question marks) so the answer only shows IF(as soon as) they clicked on the submit button? Code: [Select] <html> <body> <h2>Exercices</h2> <p> <form name="input" action="StudentAnswers.php" method="get"> Student name: <input type="text" name="user" /> </form> </p> <p> What is the gradient of T(x,y)=2x+3? <form name="input" action="StudentAnswers.php" method="get"> <input type="text" name="1b" /> <input type="submit" value="Input answer"/> </form> if ( ????????? ) { ???????"; } <?php include("QandA.php"); echo $Question["1b"];?> <p> </body> </html> B I'm not much of a PHP programmer so please excuse the mess but I'm having a problem with some code. I am able to successfully build a table and assign values to radio buttons based one information in a database. The problem comes when I want to update the database when someone changes a radio button. Everthing works up until the foreach statment. Nothing in the database is being updated, if I replace the sql statement with echo $v; all I get is the word Submit so it's like the rest of the values aren't being included in the form. <link href="css/demo.css" rel="stylesheet" type="text/css"> <?php session_start(); // dBase file include "dbconfig.php"; if (!$_SESSION["valid_user"]) { // User not logged in, redirect to login page Header("Location: index.php"); } //Grab GUID passed in the URL $guid=$_GET['guid']; // Create query for student name $sql = "SELECT FirstName, LastName FROM Students where GUID ='". $guid . "'"; // Run query $result = mssql_query($sql); $row= mssql_fetch_assoc($result); // Member only content //Title and main page information echo "<div align=\"center\"><p><img src=\"images/EFCTS Logo.jpg\" width=\"600\" height=\"144\" /></p><h1>OCAP DATABASE</h1></div>"; echo "<p><a href=\"logout.php\">Logout</a></p>"; //Build sortable table of student data. echo "<table id=\"test1\" class=\"sortable-onload-3-reverse rowstyle-alt no-arrow\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"; //query database for table information $SQLcommand = "SELECT convert(varchar(36), StudentGUID) as StudentGUID, CompetencyLevel, CompetencyName, CompetencyID, Category, convert(varchar(36), CompetencyGUID) as CompetencyGUID FROM VW_StudentSkills WHERE StudentGUID ='". $guid ."'"; $SQLresult = MsSQL_QUERY($SQLcommand); //Continue building table echo "<caption>".$row[FirstName]." ".$row[LastName]."</caption>"; echo "<th style=\"-moz-user-select: none;\" class=\"sortable-numeric fd-column-0\"><a title=\"Sort on \"Competency ID\"\" href=\"#\">Competency ID</a></th>"; echo "<th style=\"-moz-user-select: none;\" class=\"fd-column-1 sortable-text reverseSort\"><a title=\"Sort on \"Catagory\"\" href=\"#\">Catagory</a></th>"; echo "<th style=\"-moz-user-select: none;\" class=\"fd-column-2 sortable-text reverseSort\"><a title=\"Sort on \"Competency Name\"\" href=\"#\">Competency Name</a></th>"; echo "<th style=\"-moz-user-select: none;\" class=\"sortable-numeric fd-column-3\"><a title=\"Sort on \"Competency Level\"\" href=\"#\">Competency Level</a></th>"; echo "</tr></thead>"; //Set variables for radio buttons $a=""; $b=""; $c=""; $d=""; //count the number of rows returned $count=mysql_num_rows($SQLresult); //Start form echo "<form name=\"form1\" method=\"post\" action=\"".$_SERVER['REQUEST_URI']."\">"; $groupnum = 0; //Build table with SQL data while($row2=mssql_fetch_array($SQLresult)) { //find the competency level $complevel = $row2[CompetencyLevel]; if($complevel=="1") $a="checked"; if($complevel=="2") $b="checked"; if($complevel=="3") $c="checked"; if($complevel=="4") $d="checked"; //build the table echo "<tr class=\"\"><td>".$row2[CompetencyID]."</td><td>".$row2[Category]."</td>"; echo "<td>".$row2[CompetencyName]."</td>"; echo "<td class=\"lft\"><input type=\"radio\" name=\"".$row2[CompetencyID]."\" value=\"1\"".$a."> 1"; echo "<input type=\"radio\" name=\"".$row2[CompetencyID]."\" value=\"2\"".$b."> 2"; echo "<input type=\"radio\" name=\"".$row2[CompetencyID]."\" value=\"3\"".$c."> 3"; echo "<input type=\"radio\" name=\"".$row2[CompetencyID]."\" value=\"4\"".$d."> 4"; $idarray[]=$row2[CompetencyGUID]; echo "</td></tr>"; $groupnum++; //clear the variables $a=""; $b=""; $c=""; $d=""; } echo "</tbody>"; echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\">"; echo "</form></table>"; echo "<script type=\"text/javascript\" src=\"javascript/tablesort.js\"></script>"; if($_POST['Submit']) { echo"submit button detected"; foreach($_POST as $k=>$v) { if($k!="Submit") { $sqlUpdate = "UPDATE DATA SET COMPETENCYLEVEL = '".$v."' WHERE COMPETENCYGUID = '".$idarray."' AND STUDENGUID = '".$guid."' "; $resultUpdate = mssql_query($sqlUpdate); } } } if($resultUpdate) { print_r ($_POST); echo $resultUpdate; echo $sqlUpdate; } else { echo "Your entry is not completed at this time............."; echo $sqlUpdate; echo $resultUpdate; } // Display Member information //echo "<p>User ID: " . $_SESSION["valid_id"]; //echo "<p>Username: " . $_SESSION["valid_user"]; //echo "<p>Logged in: " . date("m/d/Y", $_SESSION["valid_time"]); ?> Hi there, OK, there is what I'm trying to accomplish - I want to send POST instantly when the page is loaded without "Submit" button or anything like that. Here how it looks using JavaScript: Code: [Select] <form name="postdata" action="http://www.mywebsite.com/post.php" method="post"> <input name="data" type="text" value="1"/> </form> <script type="text/javascript" language="JavaScript"> document.postdata.submit(); </script> Works fine with JavaScript, however i can't use it. Here is reference for CURL: http://php.net/manual/en/book.curl.php I found this curl_post function at php.net to simplify things up. <?php /** * Send a POST requst using cURL * @param string $url to request * @param array $post values to send * @param array $options for cURL * @return string */ function curl_post($url, array $post = NULL, array $options = array()) { $defaults = array( CURLOPT_POST => 1, CURLOPT_HEADER => 0, CURLOPT_URL => $url, CURLOPT_FRESH_CONNECT => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FORBID_REUSE => 1, CURLOPT_TIMEOUT => 4, CURLOPT_POSTFIELDS => http_build_query($post) ); $ch = curl_init(); curl_setopt_array($ch, ($options + $defaults)); if( ! $result = curl_exec($ch)) { trigger_error(curl_error($ch)); } curl_close($ch); return $result; } $test = curl_post("http://www.mywebsite.com/post.php", array("data" => "1")); print($test); ?> Looks like it uses GET instead POST (used sniffer to verify this). I'm trying to send POST data to other host, if that matters. Any help would be appreciated. Thanks in advance. I'm trying to figure out a way to post data directly to a URL. For example: <?php if (isset($_POST["pass"]) && ($_POST["pass"]=="$password")) { echo "You did it"; ?> <?php } else { echo "<form method=\"post\"><p align=\"left\">"; echo "<input name=\"pass\" type=\"text\" size=\"25\" maxlength=\"40\"><input value=\"Enter Pass\" type=\"submit\"></form>"; exit; } ?> Let's assume $password is 'password'. Why can't I simply pass the information through the URL to access the page with something like this: Code: [Select] http://mypage.com/the-same-page.php?pass=password So I have an AJAX call that I'm using to POST 1 variable to a PHP script I have on a separate server. The PHP takes this variable and returns data based off of what the variable is. This works on all browsers except IE9 and below. IE9 returns data but it's an error saying the variable is missing which to me shows that it isn't sending the data. Below I have the AJAX call I'm making:
(function (jQ) { var inviteID = '00000000000'; jQ.ajax({ url: 'www.example.com/test.php', type: 'POST', dataType: 'json', cache: false, data: { classID: inviteID }, error: function (data, status, error) { jQ('.statusField').append('Failu ' + data + status + error); }, success: function (data, status, error) { jQ('.statusField').append('Success: ' + data); } }); })(jQuery); And below I have the PHP script that's being used: <?php //first POST to grab token function runPost($classID) { $postdata = array( 'username' => 'username', 'password' => 'password' ); //open connection $ch = curl_init(); //set the url, POST data curl_setopt($ch, CURLOPT_URL, "https://www.example.com/login"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata)); curl_setopt($ch, CURLOPT_USERAGENT, 'example'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //execute post $result = curl_exec($ch); //close connection curl_close($ch); list($message, $time, $token, $userID) = split(',', $result); list($one, $two, $three, $four, $five) = split('\"', $token); $four = json_encode($four); $four = str_replace('"','',$four); $secondaryPostData = array( 'token' => $four, 'data' => array( 'invitationID' => $classID )); //open connection $chu = curl_init(); //set the url, POST data curl_setopt($chu, CURLOPT_URL, "https://www.example.com/classID"); curl_setopt($chu, CURLOPT_POST, 1); curl_setopt($chu, CURLOPT_POSTFIELDS, json_encode($secondaryPostData)); curl_setopt($chu, CURLOPT_USERAGENT, 'example'); curl_setopt($chu, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($chu, CURLOPT_RETURNTRANSFER, 1); //execute post $secondResult = curl_exec($chu); //close connection curl_close($chu); return json_encode($secondResult); } //Grab classID from javascript echo runPost(trim($_POST['classID'])); ?> Again, this works fine in everything except IE. I've tried using just $.post and even XDomainRequest() and get the same result. The network console in IE shows that the Request body does have the classID in it, but I'm guessing it's just not sending the data to the PHP script. I don't know if I'm missing something that IE needs to send this to the PHP script but any help with this would be GREATLY appreciated. Hi everyone! So, I have recently become interested in the world of webpage design and HTML coding. Thus far, I have created a few simple HTML webpages, the first of which includes some basic facts and information on the state of NC. Everything has gone rather smoothly for me until this point, but I would now like to incorporate a bit of PHP into my knowledge of web development. First, I would like to include a form on my NC page that once submitted, goes to a new PHP page displaying the inputted data to the screen. On the new page, I am attempting to include files: a header and footer. On my other couple of pages for which I would like to add server side includes. And lastly, if possible, it would be great if I could learn how to add some additional features like sending e-mails or displaying the date. Any advice or tips on how to go about this would be greatly appreciated! Hi,
I have a database which holds results
Name | Car | etc \ etc | Round 1 | round 2 | round 3 // etc | Total
the points are in the format of;
e.g.
100.5 // 25.6 // 35.8 // 50.0
I input the data manually using a webpage, clicking on the relevant driver, update scores, click submit. I have to manually work out the total, is there a way I can it it automatically add the values from round 1,2,3, etc.
Good afternoon,
I was wondering if you could help me out with a few things. I have created a registration page and it stores the information into my database. A success page then appears with some of the details they entered as a confirmation page. Unfortunately I cannot get the information to appear on the page. I have included some code, any help would be greatly appreciated.
<?php This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=346552.0 Hi everyone, First off thank you very kindly to anyone who can provide some enlightenment to this total php/mysql newb. I am creating my first database and while I have been able to connect to the database within my php script (or so I believe), the form data does not appear to be actually getting sent. I have development experience in other languages but this is completely new to me so if I've missed something that appears painfully obvious like a parse error of some sort, I do apologize. I am creating a website using Godaddy as the hosting account, and attempting to connect to the mysql database at the following URL (maybe this is where I'm going wrong): "pnmailinglist.db.4662743.hostedresource.com" Below is my very simple code: <?php //Verify successful connection to database. $connect = mysql_connect("pnmailinglist.db.4662743.hostedresource.com", "*********", "*********"); if(!$connect) {die("Could not connect!"); } //Initialize variables with form data. $firstname = $_POST['FirstName']; $lastname = $_POST['LastName']; $email = $_POST['Email']; $howfound = $_POST['HowFound']; //Post data to database, or return error. mysql_select_db("pnmailinglist", $connect); mysql_query("INSERT INTO mailinglist (First, Last, Email, How_Found) VALUES ($firstname,$lastname,$email,$howfound)"); mysql_close($connect); echo "Thank you for joining our mailing list! We will contact you soon with the dates and times of our upcoming events."; ?> Thank you again very much for any pointers or hints as to where I'm screwing up. I get no runtime errors, no syntax errors, and the echo message does display fine at the end -- just no data when I go to check my database! Best Regards, CL i am making a website where i can submit films but i am confuse to understand the structure of that where people can also submit their views and i can diferent link of diffrent companiess for example i have some example http://tv.desitvforum.net/index.php?option=com_content&task=view&id=77865&Itemid=86 http://www.funbolo.com/more.asp?itemCode=1916 this type of page that i can easily insert links and their title and images on that page there is also one problem every time become different links of different sites in different counting so that's why m more confuse ho to set data base structure for that and how add these all details from panel and people can also post comment on that well thats simple but my bug problem is structure for this aNy Body in structure Hi There, I have a series of submit buttons that I would like to update records in a table when they are pressed. For example, when clicked, I would like them to run the following statement: update mytable set completed = 1 where colname = $variable I would then like it to refresh the page. Is there a way of doing this? Thanks Matt any one? Hello, I am new to some of the rules to PHP as far as what you can POST or SEND via forms in PHP. I am attempting to change the location of a page via the header() function and basically redirect to another page if the weather is inclimate at an outdoor events center. Currently what I have is two different submit buttons that would post the header() redirect based on if the weather is good or bad. Ex. <div style="width:220px; height:50px;"> <form method="POST" action="../../weather.php"> <input type="submit" value="Good Weather" name="weather_good" /> <input type="submit" value="Bad Weather" name="weather_bad" /> </form> </div> Then the processing for the form is this file - <?php if(isset($_POST['weather_good'])){ $myFile = "../myfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = echo "<?php header ('Location:fall_festival/index.php'); ?>"; fwrite($fh, $stringData); fclose($fh); echo "Page Updated"; } else if(isset($_POST['weather_bad'])){ $myFile = "../myfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $link = "header('Location:fall_festival/weather/index.php');" ; $stringData = $link; fwrite($fh, $stringData); fclose($fh); echo "Page Updated"; } ?> The file doesn't return an error when it's processed but it also doesn't update the file header and redirect to the proper page. Thanks for your time and help! |