Web Hosting Talk







View Full Version : php help!


hoachen
08-04-2005, 11:09 AM
I am trying to write a php code that will send the data to my email account. The checkbox is write in basic html. When I selected checkbox(es) and press submit botton it will show the checkbox that I selected or "YES" and those selection will be a hyperlink that will link to other page when they click it. How to I do that? Currently I just can list it as regular text not a hyperlink. Code are list below. Right now, when I press submit it just show the successfully submited and no listing of what I have checked on the checkbox.

HTML
<input type="checkbox" name="AAA" value="AAA">AAA
<input type="checkbox" name="BBB" value="BBB"> BBB<br>
<input type="checkbox" name="CCC" value="CCC">CCC
<input type="checkbox" name="DDD" value="DDD">DDD

PHP (This part is o.k I get it on my email)
$AAA=($_POST[AAA])?"AAA: Yes":"AAA: No";
$BBB=($_POST[BBB])?"BBB: Yes":"BBB: No";
$CCC=($_POST[CCC])?"CCC: Yes":"CCC: No";
$DDD=($_POST[CCC])?"DDD: Yes":"DDD: No";

$Message.="\nArticle(s) Selected: \n\t$AAA\n\t$BBB\n\t$CCC\n\";

After press the submit botton it will display the checkboxes that are checked with hyperlink and when click on the hyperlink it will bring you to the specify site


((This part is not working)
if($AAA=="Yes")
{
echo "<a href=http://www.google.com/search?hl=en&q=flower>AAA</a>";
}
elseif($BBB=="YES")
{
echo "<a href="http://www.FTD.COM>BBB</a>";
}

elseif($CCC=="YES")

{
echo "<a href=http://www.whiteflowerfarm.com/ >CCC</a>";
}
elseif($DDD=="YES")

{
echo "<a href=www.flower.com/ >DDD</a>";
}
else
{}

OUTPUT after submitted should look like this


If i selected AAA, CCC. Those I am not select will not display
AAA<br>
CCC

hoachen
08-04-2005, 12:00 PM
already been fixed. It works now. Thank you anyone who are trying to help.


I just used this code and it works perfectly.

if(isset($_POST[AAA]))
{
echo "<a href=http://www.google> AAA<br></a>";
}

fozzy
08-04-2005, 04:27 PM
Something I don't get, why now simply use

if ($_POST['AAA'])

This does the same thing as ISSET as far as I can tell and is shorter. Is there any difference?

hoachen
08-04-2005, 04:42 PM
I don't know, it works that's matter but I will try what you have suggest. You guys are expert, I just trial an error. if I know which one is good or work then I will not post my question. Thank you very much for your suggestion.

Originally posted by fozzy
Something I don't get, why now simply use

if ($_POST['AAA'])

This does the same thing as ISSET as far as I can tell and is shorter. Is there any difference?

fastduke
08-05-2005, 12:53 AM
http://us2.php.net/manual/en/function.isset.php#35621

hoachen
08-05-2005, 01:48 PM
Well, it works on my school server but not exactly work on business server. The error I get when I submitted is Notice: Undefined index: abc in d:\html\users\205014\webaddress\html\filename.php on line xx

this error I get is when I did not select the checkbox of abc which listed on html page. If I selected all the checkboxes then it works fine. Did anybody see what's wrong?

on the html page I used javascript for validation.
if (document.contact.abc.checked==false && document.contact.def.checked==false && document.contact.ghi.checked==false)
{
alert("Please select one checkbox);
return false;
}

ON PHP
$abc=($_POST[abc])?"abc: Yes":"abc: No";
$def=($_POST[def])?"def: Yes":"def: No";
$ghi=($_POST[ghi])?"ghi: Yes":"ghi: No";

$Message.="\nArticle(s) Selected:
\n\t $abc\n\t $def \n\t $ghi\n\n";

if($_POST[abc]))
{
echo "<a href=http://www.google.com>abc<br></a>";
}

if($_POST[def]))
{
echo "<a href=http://www.yahoo.com>def<br></a>";
}

if($_POST[ghi]))
{
echo "<a href=http://www.dictionary.com>ghi <br></a>";
}







Originally posted by hoachen
already been fixed. It works now. Thank you anyone who are trying to help.


I just used this code and it works perfectly.

if(isset($_POST[AAA]))
{
echo "<a href=http://www.google> AAA<br></a>";
}