Jump to content

Posting Submitted Text Data to a New Page


mattyd

Recommended Posts

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

Link to comment
Share on other sites

do you have any code to show us thus far?

 

Yes.  So far I am using the following two files:

 

index.php

<?php
include 'connection.php';

$query = "SELECT * FROM people";

$result = mysql_query($query) or die(mysql_error());

while ($person = mysql_fetch_array($result)){

        echo  $person ['name'];
echo  $person ['descrip'];
}
?>

<H1>Add a Review:</H1>
<form action="create.php" method="post">
     <input type="text" name="inputName" value=""/>
     </br >
     <textarea cols="50" rows="4" name="inputDesc" value=""/></textarea>
     </br >
     <input type= "submit" name= "submit"/>
</form>

<html>
<head></head>
<body>
<p>The current second is <span style='font-size:16px;font-weight:bold;color:red;position:absolute;right:25px;'><?php echo time(); ?></span> on this computer.</p>
</body>
</html>

 

connection.php

<?php
$dbhost = 'mysql7.000webhost.com';
$dbuser = 'a4542527_root';
$dbpass = '*******';

$db = 'a4542527_test1';
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);

?>

 

The basic function works fine.  I am just trying to figure out how to have the text data returned/displayed to a new page after it is submitted.

 

Thanks,

Matty

Link to comment
Share on other sites

Right, when you want the detail that has been submitted to appear on another page, this is where the action attribute needs to have a value in it:-

 

<form name="myform" method="POST" action="yourProcessFileHere.php">

 

then the file (yourProcessFileHere.php in this example) has all of the code that is required to process of the contents of the form being submitted:

 

(contents of this file is something like this:-)

 

<?php

//set error reporting to on ;p
error_reporting(E_ALL);

if(isset($_POST['submit']) && !empty($_POST['submit'])){
//process your data here
}
else{
//something went wrong redirect user back to the form file/page 
}

?>

 

Using this method you can effectively 'seperate' your html processing script from the html form file that post's the data - hopefully that makes sense to you.

 

And just to clarify for the example I have used, I have named the submit button 'submit', you could assign it a value and check that that value is there to see that the form has been submitted properly.

 

Have fun.

 

Rw

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.