Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-04-2005, 07:58 AM Form Question
Novice Talker

Posts: 10
Trades: 0
Hello.

I am looking for a way to have a form on my site that as soon as the person submits the information, it posts it on another page at the site. I was wondering does anyone know of a way to do that? I know how to create a regular form to email me, but not sure how to get it posted to another site.

Thanks in advance.

Jonathan
JBrown1045 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-04-2005, 08:26 AM
andrewsco's Avatar
Super Talker

Posts: 130
Trades: 0
yer thats pretty easy to do, but perhaps even better you could put the info on the very same page...anyway here is a script I did for uni, have a look and see if you can adapt it.

PHP Code:

<?

// This connects to the database
$conn mysql_connect("128.........""dbname""password") or die(mysql_error());
mysql_select_db('northwind'$conn) or die(mysql_error());

// This gets the user input from the search box and stores it in variable $UserInput
$UserInput $_GET['search'];

// This statement queries the database using the LIKE query, to include all partial queries as well. 
$SqlQuery "SELECT CustomerID, CompanyName, ContactName, Country FROM customers WHERE CustomerID LIKE '$UserInput%' ";

// This variable stores the query results to be used later
$result mysql_query ($SqlQuery) or die('Query execution problem: ' mysql_error());
        
// Number of rowsreturned by SQL query
$number_rows mysql_num_rows($result);

// Assign the file to a variable
$File_Name "query_results.txt";

// Close IP connection
 
mysql_close($conn);

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">
  
<html>
  <head>  
   <title>Output</title>
   <meta http-equiv="content-type"content="text/html;charset=iso-8859-1" />
   <link rel="stylesheet" type="text/css" href="text.css" />
  </head>
  <body>

  <h1>Results:</h1>
    
  <p class="small">The query was :<em><?=$SqlQuery?></em></p>
  <table>
   <tr>
    <th>Customer ID</th>
    <th>Company Name</th> 
    <th>Contact Name</th>
    <th>Country</th>
   </tr>
    
   <?
     $SqlQuery 
fopen($File_Name "w") or die ("Unable to open "$File_Name);        
    
fwrite($SqlQuery"CustomerID\t CompanyName\t ContactName\t Country\n");
     
     
//While there are some rows from the result output the results
     
while($output_row mysql_fetch_array($result)) 
     {
   
?>  

        <tr>
          <td> 
            <?=htmlentities($output_row[CustomerID]) ?> 
          </td> 
          
          <td> 
            <?=htmlentities($output_row[CompanyName]) ?> 
          </td>     
      
          <td> 
            <?=htmlentities($output_row[ContactName]) ?> 
          </td>     
      
          <td> 
            <?=htmlentities($output_row[Country]) ?> 
          </td> 
       </tr>
            
            <? fwrite($SqlQuery"$output_row[CustomerID]\t"?>

            <? fwrite($SqlQuery"$output_row[CompanyName]\t"?>

            <? fwrite($SqlQuery"$output_row[ContactName]\t"?>

            <? fwrite($SqlQuery"$output_row[Country]\n"?>

   <?
     

     
fclose($SqlQuery); //Closes the file
   
?>
   </table>


    <?
        
        
if($number_rows == || $UserInput == NULL)
        {
   
?>        
            <p><a href="php_input.html">No Rows or you didn't select anything. Please Return to form</a></p>
    <?}else{?>
            <p><a href="php_input.html">Return to form</a></p>
            <p><a href="query_results.txt">Show Results in the test file</a></p>
    <?}?>

 
        <p>
      <a href="http://validator.w3.org/check?uri=referer"><img
          src="http://www.w3.org/Icons/valid-xhtml10"
          alt="Valid XHTML 1.0!" height="31" width="88" /></a>
    </p>
   




   </body>  
 </html>
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">
  
<html>
  <head>  
   <title>Database Output</title>
   <meta http-equiv="content-type"content="text/html;charset=iso-8859-1" />
   <link rel="stylesheet" type="text/css" href="text.css" />
  </head>
  <body>
  <form method="get" action="results.php">
	<p>Search for a customer: </p>
	<hr />
	<p><input type="text" name="search" /></p>
	<p><input type="submit" name="submit query" /></p>
	<p><input type="reset" name="reset" /></p>
  </form>
	<p>
      <a href="http://validator.w3.org/check?uri=referer"><img
          src="http://www.w3.org/Icons/valid-xhtml10"
          alt="Valid XHTML 1.0!" height="31" width="88" /></a>
    </p>


  </body>  
 </html>
Sco
__________________
My Webpage:
Please login or register to view this content. Registration is FREE
andrewsco is offline
Reply With Quote
View Public Profile Visit andrewsco's homepage!
 
Old 06-04-2005, 08:30 AM
Novice Talker

Posts: 10
Trades: 0
so basically I just need to fill in the red text area? Also I need to create a database? I talked to one guy who said it was unecessary. Don't know if that is true or not.
JBrown1045 is offline
Reply With Quote
View Public Profile
 
Old 06-04-2005, 03:56 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You need some way of storing the information you submit. A database is one way of doing this, and once it is set up it is the most flexible. You can acheive the same effect using flat files - this means that the PHP script that receives your data creates a text file and stores the data in it (or it might append it to the end of one big file that stores it all). Then the display script opens the file and picks out the bits it wants to display. This does not require a database, but you have to write the code to insert stuff and search for what to display.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 06-04-2005, 04:39 PM
Novice Talker

Posts: 10
Trades: 0
Quote:
Originally Posted by 0beron
You need some way of storing the information you submit. A database is one way of doing this, and once it is set up it is the most flexible. You can acheive the same effect using flat files - this means that the PHP script that receives your data creates a text file and stores the data in it (or it might append it to the end of one big file that stores it all). Then the display script opens the file and picks out the bits it wants to display. This does not require a database, but you have to write the code to insert stuff and search for what to display.
I'll do the database. Thanks for the reply. You and Andrew really helped me alot.
JBrown1045 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Form Question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.72657 seconds with 12 queries