To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Code Critique

Code Critique Having someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-21-2003, 01:03 AM   #1
kylesite
Junior Member
 
kylesite's Avatar
 
Join Date: Oct 2003
Location: here
Posts: 17
Please tell me what you think

This is one of my first PHP scripts:
PHP Code:
<?php
$to
= "webmaster@kylesite.port5.com";
echo
"
<center>
<form action=
\".$_SERVER[$PHP_SELF].\" method=\"post\">\n
<input name=
\"a\" value=\"Name\">\n
<br>
\n
<input type=
\"submit\" value=\"send\">\n
</center>
        "
;

if (isset(
$_POST['a'])){
   
$_SESSION['a'] = $_POST['a'];
echo
"Hello $_SESSION['a']. Message to $to has been sent.";
mail($to,"Name","$_POST['a'] used the form", "From:$to<Kyle>");
} else {
echo
"You didn't fill out the form!";
}
Would it work?
kylesite is offline   Reply With Quote
Old 10-21-2003, 02:17 AM   #2
LordShryku
kung foo code monkey
 
LordShryku's Avatar
 
Join Date: Aug 2002
Location: Occupational Hypnotherapy
Posts: 7,473
Well hello again

You may be better off in one of the other forums. Or maybe test your scripts before you post them. Either way...
Here we go...

$_SERVER[$PHP_SELF] <- Invalid. Should be $_SERVER['PHP_SELF']

echo "Hello $_SESSION['a']. <- Also invalid. Superglobals need to be removed from the string. Like
PHP Code:
echo "Hello ".$_SESSION['a'];
I find it good to just remove all globals from the string

Same here ->"Name","$_POST['a']

HTH
LordShryku is offline   Reply With Quote
Old 10-21-2003, 02:52 AM   #3
kylesite
Junior Member
 
kylesite's Avatar
 
Join Date: Oct 2003
Location: here
Posts: 17
It's just i am very new to PHP

What forum should I go to?
kylesite is offline   Reply With Quote
Old 10-21-2003, 02:56 AM   #4
LordShryku
kung foo code monkey
 
LordShryku's Avatar
 
Join Date: Aug 2002
Location: Occupational Hypnotherapy
Posts: 7,473
They're all ok. General Help, Newbies, Coding. Any of those would be good.
LordShryku is offline   Reply With Quote
Old 10-21-2003, 02:57 AM   #5
kylesite
Junior Member
 
kylesite's Avatar
 
Join Date: Oct 2003
Location: here
Posts: 17
This better?

PHP Code:
<?php
$to
= "webmaster@kylesite.port5.com";
echo
"
<center>
<form action=
\".$_SERVER['$PHP_SELF'].\" method=\"post\">\n
<input name=
\"a\" value=\"Name\">\n
<br>
\n
<input type=
\"submit\" value=\"send\">\n
</center>
        "
;

if (isset(
$_POST['a'])){
   
$_SESSION['a'] = $_POST['a'];
echo
"Hello ".$_SESSION['a'];
echo
"Message to $to has been sent.";
mail($to,"Name",$_POST['a']." used the form", "From:$to<Kyle>");
} else {
echo
"You didn't fill out the form!";
}
kylesite is offline   Reply With Quote
Old 10-21-2003, 03:05 AM   #6
LordShryku
kung foo code monkey
 
LordShryku's Avatar
 
Join Date: Aug 2002
Location: Occupational Hypnotherapy
Posts: 7,473
The form tag needs work....
PHP Code:
<form action="".$_SERVER['$PHP_SELF']."\" method=\"post\">\n
LordShryku is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 11:46 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.