First of all, I've just joined, so Hi to everybody.

I'm also just starting to learn php, I have what I thought would be something simple but I keep getting this error
Parse error: syntax error, unexpected T_STRING in /home/sites/poem-n-verse.co.uk/public_html/votes/process.php on line 8

Here is the code that I'm trying, thanks for looking.

<?php
$user = $_POST['user'];
switch ($user){
	case "Joe":
         $msg=$user;
         header ("Location: vote_page.php?$msg=$msg");
		break;
	case "Jack":
         $msg=$user
         header ("Location:vote_page.php?$msg=$msg");
		break;
	case "Jim":
         $msg=$user
        header ("Location: vote_page.php?$msg=$msg");
		break;
		default:
		echo "username not recognised";
		break;
}

?>

Hi ! missing semicolon in these lines.

$msg=$user << here
         header ("Location:vote_page.php?$msg=$msg");
		break;
	case "Jim":
         $msg=$user  << here

Cheers,
Naveen

Edit: Btw, this header ("Location:vote_page.php?$msg=$msg") should be header ("Location:vote_page.php?msg=$msg") , if you want to use $msg value in vote_page.php !

HI Navman
Thank you for your reply, I tried what you said but still get the error?

I will post the three pages below, maybe one is confusing the other?
The page to let you enter the name

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<body>
<table border="2" bgcolor="#c0c0c0" bordercolor="#008000" bordercolordark="#008000" bordercolorlight="#808000">
<tr><td align "center" bordercolor="#000000"><font color="#008080">
<form method="post" action="process.php" name="userID" >
<h4>Please type your Name:</h4></font>
</td>
</tr>
<tr>
<td align ="center" bordercolor="#000000"> 
<input name="user" type="text" />
</td>
</tr>
<tr>
<td align ="center" bordercolor="#000000"> 
<input type="submit" name="send" value="Submit" />
</td>
</tr>
</table>
</form>

</body>
</html>

The php code

<?php
$user = $_POST['user'];
switch ($user){
case "Joe":
$msg = $user;
header ("Location: vote_page.php?msg=$msg");
break;
case "Jack":
$msg = $user;
header ("Location: vote_page.php?msg=$msg");
break;
case "Jim":
$msg = $user;
header ("Location: vote_page.php?msg=$msg");
break;
default:
echo "username not recognised";
break;
}

?>

The result page.

<HTML>
<HEAD>
 <TITLE>Voting Page</TITLE>
</HEAD>
<BODY>
"Welcome $msg;"
</BODY>
</HTML>

Are you sure it doesn't work ? Its works on my computer though. What is the error you are getting this time ?
Edit: Btw, in voting page, you need to request msg.
ie., $msg=$_GET;

Hi Nav
Thanks for sticking with me on this,
the error is :-
Parse error: syntax error, unexpected T_STRING in /home/sites/poem-n-verse.co.uk/public_html/votes/process.php on line 8

I've placed the code $msg=$_GET; in the vote_page, I wondered how the vote page new what msg was.

Hmm.. I don't see any missing ; in the above scripts. The only thing thats wrong is,

"Welcome $msg;"

It should have been <?php echo "Welcome $msg"; ?> . But that has nothing to do with process.php. Check for missing ; in process.php . (cuz I dont see any!)

Morning Nav,
It's working, Yippee!
Thanks for all your help.
I'm off to start another thread now as I've decided to include a password with user name.

:) Great! Congrats..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.