Page 1 of 1

HELP! i got stuck showing a variable value

Posted: Tue Apr 16, 2013 7:50 am
by iAnoir
Hello all php coders,

Can you just take a few seconds to see what problem i am having in this code, i spent more than 5 hours to get the solution but without success :(

* Well let me first explain a little bit the goal of this little code,
---> First page Test.html
we have this code :

Code: Select all

 <html>
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="name">
<input type="submit">
</form>

</body>
</html>
---> Second page welcome.php // where the posted data will be submited!
we have this code:

Code: Select all

 <?php

	$an= file_get_contents('./anoir.php'); 
	$f = $_POST['name'];


	if($f == anoir){
		print $an;
} else { ''; } 
	 ?>
-----> last page where i want exactly my name be shown :) it doesn't display here that's what am asking about :/
anoir.php

some code here
variable must be display here

Code: Select all

<? echo .$_POST['name'].''; ?>
---------------------------------------------------------------------------

Re: HELP! i got stuck showing a variable value

Posted: Tue Apr 16, 2013 11:35 am
by Christopher
iAnoir wrote:

Code: Select all

<? echo .$_POST['name'].''; ?>
This code has an error. Try:

Code: Select all

<? echo $_POST['name'].''; ?>
PS - the code .'' does not really do anything. It concatenates nothing to the end of the string.

Re: HELP! i got stuck showing a variable value

Posted: Tue Apr 16, 2013 1:17 pm
by iAnoir
I do really understand what you're saying but the problem is that the value of the variable doesn't display on the page :)

/* when i am writing "anoir" in the field and submitted the form it goes to welcome.php then the if statement verify if the input field is true then it calls the function file_get_contents .. which is anoir.php ---> so here i want the variable to be displayed :) i guess this will help you to understand my goal

Please take a moment and test it yourself to better understand me, i would be glad to hear from you soon

Re: HELP! i got stuck showing a variable value

Posted: Tue Apr 16, 2013 2:52 pm
by McInfo
PHP Manual: include

Re: HELP! i got stuck showing a variable value

Posted: Tue Apr 16, 2013 5:06 pm
by iAnoir
I still need help :(

Re: HELP! i got stuck showing a variable value

Posted: Tue Apr 16, 2013 6:27 pm
by Christopher
Thanks McInfo. I am embarrassed that I missed that! Try:

Code: Select all

$f = $_POST['name'];
if($f == 'anoir'){
	include('./anoir.php');
}

Re: HELP! i got stuck showing a variable value

Posted: Tue Apr 16, 2013 7:15 pm
by iAnoir
I tried this method, it works, but there is a problem of the statement,
example,
if --> it include the first file
and
else if --> it include the second file and the first file stil on the same page :S Please help :)

Re: HELP! i got stuck showing a variable value

Posted: Tue Apr 16, 2013 9:52 pm
by Christopher
I don't understand the question. You might want to explain what you are trying to do. Your code does not make much sense.