...

View Full Version : What is the best way to retain information



ooiyh
09-01-2006, 04:29 AM
Hi,

What is the best way in php to retain a main.php form's input value on the input textbox after it has been redirected back from a sqlInsert.php for SQL proccessing?

This is what I get for using Session to retain the information after page redirecting.
Error:

<br />
<b>Notice</b>: Undefined index: script in <b>c:\inetpub\wwwroot\cyyamHub\internalweb\moviescript.php</b> on line <b>64</b><br />



This is what I did:
main.php

<textarea name="script" cols="100" rows="12" id="script"><?php echo $_SESSION['script']; /*This Session is to retain the data*/?>
</textarea>

Submit value to sqlInsert.php using submit button then redirect the page back to main.php


$gopublic = "";
$script = $_POST['script'];
$errorMsg = "";

if($script == "")
$errorMsg = $errorMsg . "+Please Fill in Something";

if($errorMsg == "")
{
$con = dbConnection();
mysql_select_db("cyyamhub", $con);

$sql="INSERT INTO moviescript (script)";
$sql=$sql . " VALUES ";
$sql=$sql . "('" . $script . "')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con);

$_SESSION['script'] = $script;
$_SESSION['err'] = "Your script have been submitted";
header('Location: ../internalweb/main.php');
}
else
{
$_SESSION['script'] = $script;
$_SESSION['err']=$errorMsg;
header('Location: ../internalweb/main.php');
}

musher
09-01-2006, 05:02 AM
are you Initialize sessions?

session_start();

is the error line (64) the first code post?

ooiyh
09-01-2006, 02:28 PM
Yes I do have the function session_start().

The strange thing is, the error doesn't occurs in Firefox, it occurs when I use IE.

rafiki
09-01-2006, 03:17 PM
IE has many errors that dont occur in firefox,
help spread firefox
http://www.spreadfirefox.com/

musher
09-01-2006, 05:53 PM
Yes I do have the function session_start().

The strange thing is, the error doesn't occurs in Firefox, it occurs when I use IE.

sessions disabled in IE ????



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum