Jump to content

Please help!! for school.


kgb49

Recommended Posts

hi all,

iam doing this php assignment and i need some help.

i need to store info of few pages using the Session statements, then show a summery and submit it using sql.

 

here is the fist page, how do i set session statements up?

 

<?php
session_start();
????????????

<!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">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Personal Information</title>
</head>

<body>
<h1>Personal Information</h1>
<form action="business.php" method="get">
<p>First Name <input type="text" name="fname" /></p>
<p>Last Name <input type="text" name="lname" /></p>
<p>Email:<input type="text" name="email" /></p>
<input name="Submit1" type="submit" value="Continue" />

</body>

</html>

 

 

~thank you in advance.

~code tags are cool

Link to comment
Share on other sites

For your first page, you don't need any PHP, you can use good old HTML.  But remember to include a </FORM> statement at the end of your form.

 

Now, the info in your form will be sent off to business.php and this is where the fun begins

 

Start your business.php file off like this :

 

<?php
session_start();
$_SESSION['fname'] = $_POST['fname'];
$_SESSION['lname'] = $_POST['lname'];
$_SESSION['email'] = $_POST['email'];
?>

 

Now you have captured the values in your form into session variables which you can now access as you surf from page to page on your site.  just remember to start each php file with session_start();

Link to comment
Share on other sites

do you know how post variables work? if so just set the post variable to its corresponding session variable. they are both arrays, so the use is fundamentally the same. you need session_start() at the top of any page that uses the session super global, but something like

$_SESSION['fname'] = $_POST['fname'];

Link to comment
Share on other sites

how do i display info that is stored in the session?

thank you.

By echoing it (or printing it, depending on your coding preferences.)

 

kgb49, if you have jumped into trying to use php, a programming language, without first having read a basic php book or at least gone through a comprehensive php tutorial, it is going to take you a very long time to get any piece of code to work and it is going to be extremely frustrating for you and for those trying to help you when you have to be told the basics.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.