?action=something

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

poopoo kaka... you have to declare the $result variable and assign it a value before it will be useful in any way...

Code: Select all

<?php
include "m_config.php";
        if(isset($_POST['action']) && $_POST['action'] == "add")
        {
                        $name = $_POST['name'];
                        $lname = $_POST['lname'];
                        $choice = $_POST['choice'];
                        $date = time();
                        $ip = GetHostByName($_SERVER['REMOTE_ADDR']);

                        if(!$name || !$lname)
                        {
                                $result = "Please fill all the required fields";
                        }
                        else
                        {
                                $query = mysql_query("insert into m_record (name,lname,yesno,date,ip) values('$name','$lname','$choice','$date', '$ip')");
                                if(!$query)
                                {
                                        $result =  "An error has occured";
                                }
                                else
                                {
                                        $result = "Thanks...";
                                }
                        }
        }
function read()
{
        global $total;

        $total = 0;

        $query = mysql_query("select *  FROM m_record where yesno='yes'");
        while($array = mysql_fetch_array($query))
        {
        $total += 1;
        }
        return  $total;
}
echo "<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<form name=\"decision\" method=\"post\" action=\"http://127.0.0.1/web/file.php\">
<input type=\"hidden\" name=\"action\" value=\"add\">
<input name=\"name\" type=\"text\">
<input name=\"lname\" type=\"text\">
<br />
<label title=\"choice\" >
yes <input name=\"choice\" type=\"radio\" value=\"yes\" checked>
No <input name=\"choice\" type=\"radio\" value=\"no\"></label>

<input type=\"submit\" value=\"submit\" />
</form> <br /> $result
".read()."
</body>
</html>";
?>
kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

then what to do !! im here asking ur help!! what should ido
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I could have sworn I just posted revised code...
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Wow.

First, you said that you know alot about PHP and only had one simple question. After you kept having trouble with your script, rather than saying thanks and politely requesting more help, you tell people to fix it?
kakapeepee wrote: that's the whole file, FIX IT
Rude.
kakapeepee wrote: then what to do !! im here asking ur help!! what should ido
I think that you should read the manual, adjust your attitude, and return here if you need more help.

P.S. TNSG just told you what to do.
kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

:)oh sorry guys if i seemed like that :$ it's just some personnal problems i have these days, and im like not being myself, so , sorry if i seemed rude.


and also regarding my previous post, i posted it when The Ninja Space Goat's post wasn't already there, so excuse me for it too.

and about my php knowledge, yes i repeat it, and say i know allot about php, but i really donno for some reason stuck today with some little problem.


i will check The Ninja Space Goat's code now :)

thx
Post Reply