Page 2 of 2

Posted: Fri Mar 10, 2006 7:30 am
by newmember
if(isset($_POST['Submit'])){
foreach($_POST as $key => $val)
{
$_SESSION[$key] = $val;
}
}

if you say that $_POST is correctly recieved then try this.(get rid of outer if())
reset($_POST);
foreach($_POST as $key => $val)
{
$_SESSION[$key] = $val;
}
also instead of writing sdo many   write str_repeat(' ',your_number_here)

Posted: Fri Mar 10, 2006 8:13 am
by 5leander5
Is this how I replace the blank spaces:

Code: Select all

<p align="center">(Please include country code) <?php str_repeat('&nbsp;',79);?>
  </p>
This does not include any of the blank spaces.

Posted: Fri Mar 10, 2006 8:41 am
by newmember
5leander5 wrote:Is this how I replace the blank spaces:

Code: Select all

<p align="center">(Please include country code) <?php str_repeat('&nbsp;',79);?>
  </p>
This does not include any of the blank spaces.
yes,that would insert 79 spaces

Posted: Fri Mar 10, 2006 8:52 am
by 5leander5
This does not result in any blank spaces at all. I cant see why..... Any ideas?

Posted: Fri Mar 10, 2006 8:54 am
by newmember
echo(str_repeat())

Posted: Fri Mar 10, 2006 8:56 am
by 5leander5
Is &nbsp the correct syntax for a blank space in PHP? I know it is in html, but not sure about php.

Posted: Fri Mar 10, 2006 11:55 am
by 5leander5
Can somebody please tell me what I am doing wrong in my html file.

In my php script, I have set the $_SESSION array successfully. I have verified this.

However, when I read the $_SESSION array in the html page to which the user is directed, it reads the $_SESSION as having a NULL value.

The start of my html file is as follows:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="ExpressionInterest" method="post" action="sendmail.php"> 
       <blockquote>
         <p align="center"><img src="Formtitle.jpg" width="852" height="286" align="middle"></p>
         <p align="center"><strong>REGISTER YOUR INTEREST </strong></p>
         <p align="center">If you would like to register your interest in attending this event, please complete and </p>
         <p align="center">return this form via fax to Norrie Keane at the following number: +353 (0)93 43887. &nbsp; </p>
         <p align="center"><strong>Title </strong>:
           <select name="Title" size="1" tabindex="1" dir="ltr">
        <option> </option>
        <option>Dr.</option>
        <option>Mr.</option>
        <option>Mrs.</option>
        <option>Miss.</option>
                       </select>    
           &nbsp;<strong> Name </strong>:<strong>
		   <?php 
		   //var_dump($_SESSION['Name']);?>   
       <input name="Name" type="text" value="<?php if(isset($_SESSION['Name'])){
		echo $_SESSION['Name'];}
		else
		echo($_POST['Name']);?>" tabindex="2" size="29">
It is the final few lines which try to read the $_SESSION variable but it returns a NULL.

Any ideas why??????? In despair!!!!!!

Posted: Fri Mar 10, 2006 12:16 pm
by R4000
Do you set the session value?

You need to do something like this:

Code: Select all

session_start();
foreach($_POST as $key=>$val){
  $_SESSION[$key] = $val;
}
empty($_POST);
echo "<pre>";
var_dump($_POST);
var_dump($_SESSION);
echo "</pre>";
This should output all the posts and sessions, and give you an idea whats happening wrong.

Posted: Fri Mar 10, 2006 12:25 pm
by 5leander5
All the $_POST and $_SESSION array elements are set correctly within the script. I have verified this. The script is as follows:

Code: Select all

<?php
session_name('myForm');
session_start();

if(isset($_POST['Submit'])){ 
foreach($_POST as $key => $val) 
{ 
$_SESSION[$key] = $val; 
} 
} 

$email = $_POST['Email'];

$body = $_POST['Title']."\n"; 
$body .= $_POST['Name']."\n"; 
$body .= $_POST['Initial']."\n"; 
$body .= $_POST['Surname']."\n"; 
$body .= $_POST['Position']."\n"; 
$body .= $_POST['Company']."\n"; 
$body .= $_POST['Address1']."\n"; 
$body .= $_POST['Address2']."\n"; 
$body .= $_POST['Address3']."\n"; 
$body .= $_POST['Country']."\n"; 
$body .= $_POST['ContactNumber']."\n"; 
$body .= $_POST['CellNumber']."\n"; 
$body .= $_POST['Email']."\n"; 
//mail( "albert_oflaherty@hotmail.com", "Expression Of Interest in Forum on Public Safety 2006", $body, "From: $email" ); 
empty($_POST);
session_write_close();
header( "Location: http://www.bertsparadise.com/ExpressionOfInterest3.php" );
?>
My problem is that when I try to read the $_SESSION from ExpressionOfInterest3.php, it gives me a NULL value.

I cannot figure out why......

Posted: Fri Mar 10, 2006 12:29 pm
by R4000
are you using

Code: Select all

session_start();
in the second page too?

because you need too :)

Posted: Fri Mar 10, 2006 12:42 pm
by a94060
use the PHP tags if your posting php code and code for HTML JAVA,etc