Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2005, 12:31 AM
Registered User
 
Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dont just look at the title , Click on to read mor

HelOO! evryone out there!! hehe!! hope u guys out there able to help me out abit.

i wanted to validate the form so i place the php_self in the form.
if all the input are all succesfully fill up!! how do i post it to another page??
pls pls pls pls helP!PP!P!



<?
if(isset($_POST["continue"]) )
{

    if($_POST["name"] == "" )
    {
        echo "Fill Up The Name ";
    }
}
?>




<form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
<br>
<br>
Name :
<input type="text" name="name">
<br>
<br>
<input type="submit" name="continue">
</form>

 
Old October 6th, 2005, 08:17 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Well, that depends on how you want to get to the next page.

For instance you can do something like this, provided that this validation happens as the very first item in the document (e.g. there is no HTML or whitespace before the opening <?php delimiter).

Code:
<?php

if(isset($_POST["continue"])  )
{
    if(empty($_POST["name"]))
    {
        $error = "Fill Up The Name ";
    }

    if (!isset($error))
    {
        // Store data here

        // Then go on to the next page
        header('Location: /path/to/next/page.php');
    }
}

?>
You should do something with the data before continuing on to next page, like store it in a database or session, otherwise that data will be lost.

Code:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<br>
<br>
Name :
<input type="text" name="name">
<?php 
    if (isset($error))
    {
        echo $error;
    }
?>
<br>
<br>
<input type="submit" name="continue">
</form>
For portability reasons you should avoid using the short tags "<?", and use the standard "<?php" as the opening delimiter.

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old October 6th, 2005, 08:46 AM
Registered User
 
Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thnks for your reply buddy!! !!!!(Y) owe u 1






Similar Threads
Thread Thread Starter Forum Replies Last Post
I dont know what the topic is?! Apocolypse2005 Beginning VB 6 3 August 20th, 2007 12:44 PM
Sessions dont work melkin ASP.NET 1.0 and 1.1 Professional 6 April 12th, 2007 01:17 PM
Read Report title cvamin Crystal Reports 0 September 11th, 2006 08:10 AM
Samples dont work Jags .NET Framework 2.0 1 April 22nd, 2005 09:39 AM
I dont understand what this program does? kyootepuffy Classic ASP Databases 2 September 9th, 2003 01:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.