Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,264 members, 7,807,907 topics. Date: Wednesday, 24 April 2024 at 10:17 PM

Help With Html/php Form Preview - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Help With Html/php Form Preview (4342 Views)

What Can One Do With Html / Introducing Textpad - A Software To Quickly Learn Web Development With HTML,CSS / How To: Create A Simple Hover Button With Html And Css (2) (3) (4)

(1) (2) (Reply) (Go Down)

Help With Html/php Form Preview by kok(m): 2:27pm On Mar 21, 2011
Hello Masters,

I am working on a registration form, I have successfully created the form, parse it and submit to a database. But I want to add a Preview page in between such that user can be able to preview what they 've entered and edit if need be before submitting.

I need someone to help me out with this please!
Re: Help With Html/php Form Preview by Nobody: 6:50pm On Mar 21, 2011
If i get you correctly, you created a form, when users fill it, it saves the form datas in a DB.(Meaning you know your way around inserting things to a DB)

But after users fill the form, you need to show them the form again, and they preview for a last time before inserting and possibly correct errors.

There are many ways to get around this:

1. You could use two tables, query what has been submitted and show it to the user inside a field in a new page like confirm_signup.php then they re-submit and it hit's a table(I personally would not use this method)

It will waste time and is just amateurish.

2. Use session and save those fields filled, and move them to the new page confirm to PHP, then echo them inside a form field for correction and submitting!

If you don't understand pls seek further explanation, and if you need codes, please request!
Re: Help With Html/php Form Preview by Nobody: 7:00pm On Mar 21, 2011
u have 2 choices Javascript or Server sided
Re: Help With Html/php Form Preview by Nobody: 7:01pm On Mar 21, 2011
will explain later work
Re: Help With Html/php Form Preview by kok(m): 7:51pm On Mar 23, 2011
@Donpuzzo; Thanks for your response. I know my way round inserting the data to the DB.
Donpuzo:


x. Use session and save those fields filled, and move them to the new page confirm to PHP, then echo them inside a form field for correction and submitting!

If you don't understand pls seek further explanation, and if you need codes, please request!

Please how do I go about the above? I will appreciate if you are able to provide me codes with explanation, my email addy is wrex001@yahoo.ca. I could send you what I have already done if you would like to go through, Thanks a zillion!

@guru, Javascript of Server sided, got no clue. I can only think of PHP/MySql. Either way. I appreciate your response, Thanks!
Re: Help With Html/php Form Preview by Nobody: 10:07pm On Mar 23, 2011
it is also possible to save the entire form into a single session variable using serialization

$_SESSION['myform']=$_POST; //that saves the entire post array.

and you can later say something like below later on when you get back to the form:
$_POST=$_SESSION['myform'];

echo $_POST['first_name'];


Alternatively, you could use javascript - some simple display stunts, or you could use something
like jquery thickbox to do preview without actually leaving the page. . .

Hello everyone, i have been out of circulation for awhile, great to see you guys (. . .slips back undercover)

- hasta la vista everyone!
Re: Help With Html/php Form Preview by Nobody: 10:45pm On Mar 23, 2011
@Tony. Which will you use!

Be sincere and don't be bias in favor of Client([size=2pt]Cause na you be the definition of Client side[/size]) else me and you go start war.

By the way. This days you don dey show pride for me. We no dey chat again.

Ou revour Monsiour Tony!

Did i get the spelling My Teacher?
Re: Help With Html/php Form Preview by Nobody: 7:12am On Mar 24, 2011
@kok will send to your mail tomorrow from work.but its Client side i will be using
Re: Help With Html/php Form Preview by yawatide(f): 10:31am On Mar 24, 2011
@dhtml: Interesting.  Never knew of that.  Slyrox, if you are out there, are there any security implications of dhtml's method?

Thanks for sharing dhtml, and welcome back smiley
Re: Help With Html/php Form Preview by Nobody: 1:39pm On Mar 24, 2011
Donpuzo:

@Tony. Which will you use!

Be sincere and don't be bias in favor of Client([size=2pt]Cause na you be the definition of Client side[/size]) else me and you go start war.

By the way. This days you don dey show pride for me. We no dey chat again.

Ou revour Monsiour Tony!

Did i get the spelling My Teacher?
Since the post says php, so i will use php. personally i will use php. I only javascript when necessary or when the client demands it.

Well, to clarify things, i have done a php sample code under like 20 minutes and have posted it. Here is the link

http://.net/demos/phpformpreview

I tried to simplify it as much as possible.
yawa-ti-de:

@dhtml: Interesting.  Never knew of that.  Slyrox, if you are out there, are there any security implications of dhtml's method?

Thanks for sharing dhtml, and welcome back smiley

thanks, please comment on the sample code. What i did is pure php, to secure it, you need to be more specific.

btw serialization is one important ingredient in saving sessions to database.

you can say: $mysession=serialize($_SESSION);
and then mysql_query(, );
but in reality, the session save handlers and stuffs are used. . . .

- slips back undercover. . .

- see you folks later.
Re: Help With Html/php Form Preview by Nobody: 1:41pm On Mar 24, 2011
which reminds me, in my earlier post i said - $_SESSION['myform']=$_POST
i think i will modify it to $_SESSION['myform']=serialize($_POST);
and i did demonstrated how to use serialization in the sample code i provided

- aasta la beestar!
Re: Help With Html/php Form Preview by kok(m): 3:23pm On Mar 24, 2011
Many thank  for all the response, speechless I am, but I can afford to take a bow for the masters.

@dhtml;
*dhtml:

it is also possible to save the entire form into a  single session variable using serialization

$_SESSION['myform']=$_POST; //that saves the entire post array.

and you can later say something like below later on when you get back to the form:
$_POST=$_SESSION['myform'];

echo $_POST['first_name'];


I have tried using the above method but I dont to it is suppose to work. I am processing the form on the say page as the form. I used $_SESSION['myform']=$_POST; at the beginning of my code and $_POST=$_SESSION['myform']; just before the INSERT and echo $_POST['first_name']; I am not sure where to use it.

My result;  the form keep giving me thesame result while inserting the data to the db. Please can you give a kinda explanation on how to apply your method. Apologies in advance cuz I am "newbie".

@pc guru; I will expect your mail and hope it would be comprehensive for me to grasp.

@everyone,  Thanks, with a bow!
Re: Help With Html/php Form Preview by Nobody: 6:56pm On Mar 24, 2011
i have corrected the error, and i have posted a sample code on http://.net/demos/phpformpreview

a complete and working sample code for that matter also. . .
Re: Help With Html/php Form Preview by kok(m): 8:27pm On Mar 24, 2011
@dhtml; Thanks a zillion. I have just download the script and going through it now. Very different from what I've already done and kinda complex cuz am working with 12 inputs, and trying to preview the input in a table (to make it display neatly) . I will have to relax my head to be able to understand your code, assignment for me tonight. I truly appreciate your goodwill, you are da bomb, no! Thumbs up, not bomb abeg!
Re: Help With Html/php Form Preview by Nobody: 8:36pm On Mar 24, 2011
i will rather prefer <?php strrev("bomb"wink;?>

you are welcome. sorry, i did not know you were a beginner.

pero am not sure of how to simplify it. but i do know those codes
are not for beginners.
you are free to ask any question concerning any lines in the code,
i wrote it all myself on the fly. . .so i suppose i understand it well.
Re: Help With Html/php Form Preview by yawatide(f): 8:44pm On Mar 24, 2011
dhtml, though we have had this conversation before and you tend to disagree, the last post is the very reason why I say that when you write code, you have to write it with the assumption that someone else will need to reuse it and understand it, for maintenance reasons.

Sure, you wrote it yourself and sure, it works but of what use is it if, at the very least, you don't add comments, so that others can understand?
Re: Help With Html/php Form Preview by Nobody: 10:27pm On Mar 24, 2011
Ok, Thought of this this morning while trying to write session codes and reasoned that it may even be unnecessary using session, if the forms will be in one page.

You could do something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Donpuzo" />
<title>Untitled 1</title>
</head>
<body>
<h1>Welcome: Please fill this Form and submit to signup</h1>
<form method="POST" action="confirm_page.php">
<label>Username</label>


<input type="text" name="username"/>


<label>Name</label>


<input type="text" name="name"/>


<label>Password</label>


<input type="password" name="password"/>
<input type="submit" value="Submit Form"/>
</form>
</body>
</html>

Above is the HTML form for example:

<?php

/**
* @author Donpuzo
* @copyright 2011
*/

$username=$_POST['username'];
$name=$_POST['name'];
$password=$_POST['password'];

print<<<form
<p>Please confirm that the datas you entered is correct</p>
<form method="POST" action="formhandler.php">
<label>Username</label>


<input type="text" name="username" value="$username"/>


<label>Name</label>


<input type="text" name="name" value="$name"/>


<label>Password</label>


<input type="text" name="password" value="$password"/>
<input type="submit" value="Confirm Now!">
</form>
form;

?>

Here is the PHP
Re: Help With Html/php Form Preview by Nobody: 10:45pm On Mar 24, 2011
Save the PHP code as confirm_page.php

Only if you have a many paged form you might use session to save the entered field and show it out for correction.

Now in the PHP page that will receive the form values from the confirm_page.php

You can then insert into a DB.
Re: Help With Html/php Form Preview by Nobody: 11:42pm On Mar 24, 2011
yawa-ti-de:

dhtml, though we have had this conversation before and you tend to disagree, the last post is the very reason why I say that when you write code, you have to write it with the assumption that someone else will need to reuse it and understand it, for maintenance reasons.

Sure, you wrote it yourself and sure, it works but of what use is it if, at the very least, you don't add comments, so that others can understand?
well. . .ehm. . .it looks like a rather short code. . . .figure it out yourself. . .

the code is open source, someone else can help write comment - my bad. . .

lol. . .copyright don puzo. . .this might be a better option sha

- hasta manana everyone
Re: Help With Html/php Form Preview by Nobody: 11:47pm On Mar 24, 2011
Na Author be Donpuzo, Copyright 2011.

It was not like i wrote those shitz. Who get time for that.

If you have used PHPDesigner, you will know that it always show that on every file
Re: Help With Html/php Form Preview by Nobody: 5:05am On Mar 25, 2011
I use phpdesigner 2007 sha, i was just tripped at the copyright stuff. . .rather amusing. . .

Eyin boyz, today na my buffday o! i no suppose dey right code, but here am i, at 5.00am
coding again. . . .awon clients no go gree make i no write codes o!
Re: Help With Html/php Form Preview by Nobody: 7:44am On Mar 25, 2011
@dhtml for real,wheres the party at?so is there gonna be booze,and most importantly are the ratio of babes gonna be twice the no o f boys.and also th most vital question.hope u inviting bad babes and not good babes,omo if all is yes sharp sharp just send ur address to me.i fit kip work cuz of ur party.Happy Birthday
Re: Help With Html/php Form Preview by Nobody: 7:49am On Mar 25, 2011
@kok i need to see the page u want to preview first.
Re: Help With Html/php Form Preview by Nobody: 11:48am On Mar 25, 2011
Happy Bday Dhtml, pc has spoken my mind!
Re: Help With Html/php Form Preview by talk2hb1(m): 1:10pm On Mar 25, 2011
mail me at talk2hb1[at]gmail.com i have a complete code for that cos am working on similar project right now
Re: Help With Html/php Form Preview by kok(m): 5:49pm On Mar 25, 2011
Happy birthday to you Dhtml, wish you more glorious years ahead.

@Donpuzzo; Thanks for the code. I am doing fine with it, though having a "parse error" on the last line, right on the closing php tag, I hope it has nothing to do with your copy-right/ing cuz I took it off.

@ everyone, Thanks !
Re: Help With Html/php Form Preview by Nobody: 7:16pm On Mar 25, 2011
You may post the one that flagged off parse error. Cause i tested the thing before posting.
Re: Help With Html/php Form Preview by kok(m): 9:06pm On Mar 25, 2011
nothing is on the the line that flagged the "parse error". its just ">?" . am just trying to go through the codes in between to see what could have gone wrong. If it doesnt have to do with your[b] /**
* @author Donpuzo
* @copyright 2011
*/[/b]

Then I should be able to fix it.

Thanks a zillion bro.
Re: Help With Html/php Form Preview by Nobody: 9:45pm On Mar 25, 2011
if the last line has ">?" then it's wrong it should be ?>

If you think the copyright thing is the problem. Here is the code, without a copyright notice.

<?php
$username=$_POST['username'];
$name=$_POST['name'];
$password=$_POST['password'];

print<<<form
<p>Please confirm that the datas you entered is correct</p>
<form method="POST" action="formhandler.php">
<label>Username</label>


<input type="text" name="username" value="$username"/>


<label>Name</label>


<input type="text" name="name" value="$name"/>


<label>Password</label>


<input type="text" name="password" value="$password"/>
<input type="submit" value="Confirm Now!">
</form>
form;
?>
Re: Help With Html/php Form Preview by Nobody: 1:26pm On Mar 26, 2011
without reading the poster, i thought it was don puzo that posted that babes stuff. well, the answer is No. . . .to all. . .lo siento. . .
but i did spent it with a rather special babe sha. . .

now, i hope you guys have rescued the OP? as for me, i don xcape commoth for here. . .

thanks all for wishing me a happy bday (*runs quickly outta the thread*)
Re: Help With Html/php Form Preview by kok(m): 5:16pm On Mar 28, 2011
@ All; thanks a whole lot.

@Donpuzo, I finally got through with your code, works fine. Curiosity got me to read further and I found another way of achieving thesame purpose using "value increment" and hidden fields, all on one page. works fine.

Thanks all thesame.
Re: Help With Html/php Form Preview by Nobody: 6:42pm On Mar 28, 2011
kok:

@ All; thanks a whole lot.
@Donpuzo, I finally got through with your code, works fine. Curiosity got me to read further and I found another way of achieving thesame purpose using "value increment" and hidden fields, all on one page. works fine.
Thanks all thesame.

The Bolded makes me happy. That's a sign of a good coder in the making. Tries to make long and many paged codes shorter!

(1) (2) (Reply)

Get Free Twitter Followers (tricks) / How Do I Claim My Google Adsense In Nigeria / How Cloudflare Can Help Secure Your Wordpress Site

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 49
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.