Solved

Including a form page in an action page

Posted on 2004-03-28
5
197 Views
Last Modified: 2006-11-17
Hi,

I am new to php. Hope some kind souls out there can help me out.

Basically, my scenario is that a user can create an account for himself through a form. However, due to some validation, an error message is displayed to him. I would like to include the form page that he had filled up(including whatever values he had entered) below the error message in the action page. I understand that the include function can be used but not quite sure how.

Hope someone can help me out. Thanks.

Rio
0
Comment
Question by:deadmanincsg
5 Comments
 
LVL 6

Accepted Solution

by:
CosminB earned 125 total points
ID: 10701347
<?php
include 'form.html';
//or
include 'form.php'
?>
http://www.php.net/include
or
http://www.php.net/require
0
 
LVL 17

Assisted Solution

by:dorward
dorward earned 125 total points
ID: 10701836
and edit the form such:

<input name="foo" value="<?php print htmlspecialchars(stripslashes($_REQUEST['foo'])); ?>">

... to preserve the data he submitted.
0
 
LVL 1

Expert Comment

by:mikrotuho
ID: 10798203
Methinks that this scenario could be taken care of with one multipurpose page: thispage.php.
<html>

<?php
if (1==$_GET['isinputok'])://Check to see whether user submitted incorrect information
?>
HTML telling him of his sin
//Since isinputok!=2 then the form will be displayed again. The code by dorward can be used
//to display the form input (I think).
<?php
else:

if (2==$_GET['isinputok']{
//Process form input
if input is wrong then call this page with 'thispage.php?isinputok=1'
if input is ok then do what you need to do
}
?>

//Here we have the form in php or html. This is where the script starts when the page is
//first called (isinputok is not set to anything), or if the user submitted incorrect information.
//ie. isinputok==1.
HTML FORM

//In the action part of the form this same page needs to be called with 'thispage.php?isinputok=2'
//for this to work.

<?php
endif;
}
</html>

I hope this makes some sense to you,

Mikrotuho
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Permalink issue in Wordpress archive 1 33
wamp versus xampp 4 45
PHP_POST() error message 9 42
Form not operating correctly. 1 23
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now