| | |
Help
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2006
Posts: 12
Reputation:
Solved Threads: 0
Hi,
I am a beginner trying to learn PHP.
I have created two Files -one HTML page and another is a PHP file.
HTML page-Form page
PHP file- Does the Evaluation.
HTML code:
<form action="Samplepgm.php" method="post">
Your Name : <input type="text" name="name"><br><br>
E-mail : <input type="text" name="email"><br><br>
Comments: <br> <textarea name="comments"> </textarea><br><br>
<input type="submit" value="submit"><br>
</form>
PHP code:
function checkOK($field)
{
if(eregi("\r",$field) ||eregi("\n",$field))
{
die("invalid input!");
}
}
$name=$-POST['name'];
checkOK($name);
$email=$_POST['email'];
checkOK($email);
$comments=$_POST['comments'];
checkOK($comments);
$to="ootyviji@yahoo.co.in";
$message="$name just filled in your comments form.They said:\n$comments\n\nTheir email address was : $email"; if(mail($to,"comments fro your site",$message,"From: $email\n")) echo "Thanks for your comments"; else echo " There was a problem sending mail. Please check that you filled in the form correctly";
}
I am running this code on Apache web server.
I found this code in one of the tutorials , i just tried and copied, but its not working..Shd i need to configure or add any code in php.ini or httpd.conf to execute ???
I have stored the php file in htdocs folder that follows the path in Program files Folder.
when i typed localhost/callmail.html ... The outcome what i see in my browser is all my PHP code.
could anyone suggest me where i went wrong???
And one more thing i would like ask is .... Instead of storing php file in Htdocs folder, Can i set the path so that i can save all the php file in a seperate folder. How would i do it???
Thanks,
viji
I am a beginner trying to learn PHP.
I have created two Files -one HTML page and another is a PHP file.
HTML page-Form page
PHP file- Does the Evaluation.
HTML code:
<form action="Samplepgm.php" method="post">
Your Name : <input type="text" name="name"><br><br>
E-mail : <input type="text" name="email"><br><br>
Comments: <br> <textarea name="comments"> </textarea><br><br>
<input type="submit" value="submit"><br>
</form>
PHP code:
function checkOK($field)
{
if(eregi("\r",$field) ||eregi("\n",$field))
{
die("invalid input!");
}
}
$name=$-POST['name'];
checkOK($name);
$email=$_POST['email'];
checkOK($email);
$comments=$_POST['comments'];
checkOK($comments);
$to="ootyviji@yahoo.co.in";
$message="$name just filled in your comments form.They said:\n$comments\n\nTheir email address was : $email"; if(mail($to,"comments fro your site",$message,"From: $email\n")) echo "Thanks for your comments"; else echo " There was a problem sending mail. Please check that you filled in the form correctly";
}
I am running this code on Apache web server.
I found this code in one of the tutorials , i just tried and copied, but its not working..Shd i need to configure or add any code in php.ini or httpd.conf to execute ???
I have stored the php file in htdocs folder that follows the path in Program files Folder.
when i typed localhost/callmail.html ... The outcome what i see in my browser is all my PHP code.
could anyone suggest me where i went wrong???
And one more thing i would like ask is .... Instead of storing php file in Htdocs folder, Can i set the path so that i can save all the php file in a seperate folder. How would i do it???
Thanks,
viji
•
•
Join Date: Mar 2006
Posts: 12
Reputation:
Solved Threads: 0
Hi Sam,
Refer to this site http://www.thesitewizard.com/archive/apache.shtml to install Apache Server.
They have clearly given the step by step instruction to install Apache Server. Just follow the instruction and ur work will be done. It should not be any problem in installing. I think it will be handy.
Good Luck.
Cheers,
Viji
Refer to this site http://www.thesitewizard.com/archive/apache.shtml to install Apache Server.
They have clearly given the step by step instruction to install Apache Server. Just follow the instruction and ur work will be done. It should not be any problem in installing. I think it will be handy.
Good Luck.
Cheers,
Viji
•
•
•
•
Originally Posted by Viji
And one more thing i would like ask is .... Instead of storing php file in Htdocs folder, Can i set the path so that i can save all the php file in a seperate folder. How would i do it???
And then use a directory for PHP work, this can be changed by editing the doc_root in php.ini.
Sorry didn't get looking at the code as I have to go, someone maybe willing to help soon though.
![]() |
Other Threads in the PHP Forum
- Previous Thread: Unexpected T_String: I'm not seeing it
- Next Thread: php script displays the source code on invokation
Views: 1401 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube





