Solved

Including a form page in an action page

Posted on 2004-03-28
5
196 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
Comment Utility
<?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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

763 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

6 Experts available now in Live!

Get 1:1 Help Now