I am trying to get data from a form and send it to another page using sessions only. Without using post
I have read this but if i put the page name in the action atribute, the script is not executed, and the action is always performed first when the button is pushed.
Here is my solution
<html>
<body>
<h3>a) Inserir uma nova pagina: </h3>
<form action="" method="post">
<p>userid: <input type="text" name="input_userid"/></p>
<p>Nome de Nova Pagina <input type="text" name="input_nova_pagina"/></p>
<p><input type="submit" name="Submit" value="Adicionar nova pagina!"/></p>
<?php
session_start();
if (isset($_POST['Submit'])) {
$_SESSION['userid'] = $_POST['input_userid'];
$_SESSION['nova_pagina'] = $_POST['input_nova_pagina'];
header('Location: /xampp/Aptana/BDproj2/addp.php');
}
?>
</form>
</body>
The Second page is:
<?php
session_start();
?>
and this
<html>
<body>
<?php
echo "Favorite color is " . $_SESSION["userid"] . ".<br>";
echo " nome da pag : " . $_SESSION["nova_pagina"];
//$userid = $_REQUEST['input_userid'];
//$nova_pagina = $_REQUEST['input_nova_pagina'];
?>
</body>
Is there a better way to do what i want? i hope i was clear.