A simple PHP Question


hey guys,

   learning basic php make simple form, , have quick question. have these 2 test php files, form.php , acion.php. enter in on form posted via $_post action.php gets displayed. here test sites:

 

http://christianstest.info/phptest/form.php

http://christianstest.info/phptest/action.php

 

and code two, verry simple:

 

form.php

<!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 http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php form test</title>
</head> 
<body>
<form action="action.php" method="post">
<p>your name: <input type="text" name="name" /></p>
<p>your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p> </form> 
</body>
</html>

 

and action.php


<!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 http-equiv="content-type" content="text/html; charset=utf-8" />
<title>untitled document</title>
</head> 
<body>
hi <?php echo htmlspecialchars($_post['name']); ?>. <?php echo (int)$_post['age']; ?> years old.
</body>
</html>

 

 

now want have action.php store data entered form.php link directly action.php , see whatever last user entered form.php. of right now, if go directly uncached action.php displays nothing name , age respectivly. how can data stick? if in fact not simple question, can point me tutorial? thanks!

form.php

 

<?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 http-equiv="content-type" content="text/html; charset=utf-8" />

<title>php form test</title>

</head>

<body>

<form action="action.php" method="post">

<p>your name: <input type="text" name="name" /></p>

<p>your age: <input type="text" name="age" /></p>

<p><input name="submit" type="submit" /></p>

</form>

</body>

</html>

 

 

 

 

action.php

 

<?php session_start(); ?>

<?php if (array_key_exists('submit', $_post)) { ?>

<?php

$_session['name'] = $_post['name'];

$_session['age'] = $_post['age'];

?>

<?php } ?>

 

<!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 http-equiv="content-type" content="text/html; charset=utf-8" />

<title>untitled document</title>

</head>

<body>

hi <?php echo $_session['name']; ?>.

you <?php echo $_session['age']; ?> years old.

</body>

</html>



More discussions in Dreamweaver support forum


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account