Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-27-2006, 02:08 PM   #1 (permalink)
rkc444
Junior Member
 
Join Date: Jun 2006
Posts: 2
Default go to new page after posting data

Sorry, but I just posted this without the PHP tags. Here it is again, with tags. I am having trouble figuring out how I post data, and then go to another web page. One or the other seems easy. In one page I have the following line which handles the posting of the data:

PHP Code:
<form name="Summission" method="post" action="<?php echo $PHP_SELF;?>">

And I have another which page where I do not post data, but simply go to another web page:

PHP Code:
<form enctype="multipart/form-data" action="https://depts.washington.edu/isei/FileUploadOnlyISEI.php" method="POST"

I am not sure how to post data, as in the first page, and then go to another page. I would appreciate any help you might offer.

It seems like it should be common and easy. Any help? Thanks in advance.
rkc444 is offline   Reply With Quote
Sponsored Links
Old 06-28-2006, 02:21 AM   #2 (permalink)
etono
Moderator
 
Join Date: May 2006
Posts: 86
Default Re: go to new page after posting data

In the first case where you are posting to the same page you would need to redirect to another page... something like this:

PHP Code:
<?php
header
'location: http://domain.com/newpage.html' );
?>

Be sure that you are redirecting before anything is output.
__________________
Jeremy Moseley
My Links: Design Related Blog | Personal Website | Portfolio
etono is offline   Reply With Quote
Old 06-28-2006, 01:27 PM   #3 (permalink)
rkc444
Junior Member
 
Join Date: Jun 2006
Posts: 2
Question go to new page after posting data

That is my problem. I understand that the header function has to be executed prior to any output, and thus prior to writing to the MySQL table, if I am not mistaken. So how do I write to the table and then end up at another page? Or if I have already gone to the other page, how do I then write the data to the table?
rkc444 is offline   Reply With Quote
Old 06-28-2006, 04:44 PM   #4 (permalink)
etono
Moderator
 
Join Date: May 2006
Posts: 86
Default Re: go to new page after posting data

Writing to your database does not output anything. By output, I mean displaying to the screen. Here is how I normally go about it:

PHP Code:
<?php
if( isset( $_POST['name'] ) && isset( $_POST['phone'] ) && isset( $_POST['email'] ) ) {
    
    
//assuming open database connection
    
$sql "INSERT INTO contacts ( name, phone, email ) VALUES ( '{$_POST['name']}', '{$_POST['phone']}', '{$_POST['email']}' )";
    
mysql_query$sql );
    
header'location: thankyou.php' );
    exit();
}
?>
<html>
<head>
<title>contact Form</title>
</head>
<body>
<form action="<?php echo $PHP_SELF?>" method="post">
Name:<input type="text" name="name" value="<?php echo $_POST['name']; ?>" /><br />
Phone:<input type="text" name="phone" value="<?php echo $_POST['phone']; ?>" /><br />
Email:<input type="text" name="email" value="<?php echo $_POST['email']; ?>" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>

Of course I would do some validation on the post variables before checking to see if they are set, and adding it to the database, but hopefully this can give you a good starting point.
__________________
Jeremy Moseley
My Links: Design Related Blog | Personal Website | Portfolio
etono is offline   Reply With Quote
Old 08-19-2006, 08:49 AM   #5 (permalink)
8ta8ta
Junior Member
 
Join Date: Aug 2006
Posts: 25
Default Re: go to new page after posting data

If there are some output, You can use javascript to location :

location.href = '/aaa.php';
8ta8ta is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:39 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums