Forum : code in browser
Brief description  about Online courses   join in Online courses
View Noor  Mohammed 's Profile

code in browser

Hello sir,

I am getting part of the php code in my browser, may I know why is this.

Many thanks to you.
Asked by Noor Mohammed | Jan 20, 2011 |  Reply now
Replies (3)
View teacher siliconindia 's Profile
You have a problem in putting your php file(form.php) in the www directory


keep it in C:\wamp\www\form.php

always put your php file uder www folder beacause c:\wamp\www is the path for localhost so that you can access your page by typing in browser http://localhost/form.php
Jan 31, 2011
View noor mohammed 's Profile
here is the code:

<?php

echo $_POST['name'];
echo $_POST['age'];
echo $_POST['occupation'];

if ($_POST['submit'])
{

$name = $_POST['name'];
$age = $_POST['age'];
$occupation = $_POST['occupation'];

$errorstring = "";

if (!$name)
$errorstring = $errorstring.'Name<br>';

if (!$age)
$errorstring = $errorstring.'Age<br>';

if (!$occupation)
$errorstring = $errorstring.'Occupation<br>';

if ($errorstring = "")

echo 'Please fill out the following fields:<br>'. $errorstring;

else
{
die("success!");
}

}

?>

and this I see in the browser:


Notice: Undefined index: name in C:\wamp\www\form.php on line 41

Notice: Undefined index: age in C:\wamp\www\form.php on line 42

Notice: Undefined index: occupation in C:\wamp\www\form.php on line 43

Notice: Undefined index: submit in C:\wamp\www\form.php on line 45

May I please know what is the problem here?
Jan 22, 2011
View teacher siliconindia 's Profile
It seems that you are running your php file without help of apache server.

run your code in the directory http://localhost/filename.php or http://127.0.0.1/filename.php and also make sure that server is running or not.

Because PHP is a server side scripting language and it is parsed at server site. without server a php file is just like a text file.

Hope you have got more idea about this issue.

Get back if facing the same problem again
Jan 21, 2011