php-general Digest 18 Jan 2004 22:56:50 -0000 Issue 2538

Topics (messages 174963 through 174980):

Re: Is this possible ?
        174963 by: Toby Irmer
        174964 by: Dave Carrera
        174965 by: Dave Carrera
        174966 by: Larry Brown
        174967 by: DvDmanDT

Error Reporting help
        174968 by: Chris Edwards
        174970 by: Adam i Agnieszka Gasiorowski FNORD
        174971 by: John W. Holmes

compare lists
        174969 by: mayo
        174972 by: Richard Davey
        174973 by: mayo
        174974 by: mayo

Converting PHP code to class
        174975 by: Joe Harman
        174979 by: Manuel Lemos

recompiling php
        174976 by: John

Using lists over newsgroup, Problem
        174977 by: siamak

migrating OOP ver4 codes to 5
        174978 by: siamak

Re: Please reply as fast as possible..
        174980 by: Chris W

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
One way:

<?
Function MyFunc()
{
    if(isset($_POST[var])){
        $sql = mysql_query("select * from table_name where
field=\"$_POST[var]\"");

        $num = mysql_num_rows($sql); // I want to use this result outside
this function.

        $returnsomething ="blah blah";
     }
    return array($returnsomething, $num);
}

list($text, $numrows) = MyFunc();
?>

hth

toby

----- Original Message -----
From: "Dave Carrera" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 18, 2004 11:22 AM
Subject: [PHP] Is this possible ?


Hi List,

I have a function that makes a call to mysql based on certain vars.

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");
 $returnsomething ="blah blah";
 }
 return $returnsomething;
}

And that all works fine no probs here but.....

I want to use a result somewhere in my script that is not returned by
return. Let me show you...

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");

 $num = mysql_num_rows($sql); // I want to use this result outside this
function.

$returnsomething ="blah blah";
 }
 return $returnsomething;
}

So $num contains a number that I want to use outside the function which is
not covered by return.

I know return stops a script and returns what I want it to return but how do
I send out of the function the var I want.

I have tried $GLOBAL[var]=$num; but that don’t work, but I thought I
would'nt anyway just tried it and yes I know I have to declare it inside my
new function using global $var; to use it.

So I ask is this achiveable or how can I do this.

Thank you in advance

Dave C


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Thanks Toby,

But I forgot to mention something that makes retuning an array not usable in
the context of my needs.

<?
Function MyFunc()
{
    if(isset($_POST[var])){
        $sql = mysql_query("select * from table_name where
field=\"$_POST[var]\"");
           
                $num = mysql_num_rows($sql); // I want to use this result
outside this function in another function elsewhere.       
        While($rows = mysql_fetch_array($sql){
   
    $returnsomething .="blah blah";
        }
     }
        return $returnsomething;
    // return array($returnsomething, $num); // your suggested answer
}

// list($text, $numrows) = MyFunc(); // Your suggested answer
?>

As you can see with my ammeded example I am already returning and array.

I thought I could cast the result $num into the $GLOBAL array for use later
but that dose not seem to work or be do able.

I could relicate the function and call it something else say MyFunc2() but
that seems a waste of code and mysql connection load when I am already
retrieving the var I want to use.

Any further ideas are appreciated.

Dave C

-----Original Message-----
From: Toby Irmer [mailto:[EMAIL PROTECTED] 
Sent: 18 January 2004 10:29
To: Dave Carrera; [EMAIL PROTECTED]
Subject: Re: [PHP] Is this possible ?


One way:

<?
Function MyFunc()
{
    if(isset($_POST[var])){
        $sql = mysql_query("select * from table_name where
field=\"$_POST[var]\"");

        $num = mysql_num_rows($sql); // I want to use this result outside
this function.

        $returnsomething ="blah blah";
     }
    return array($returnsomething, $num);
}

list($text, $numrows) = MyFunc();
?>

hth

toby

----- Original Message -----
From: "Dave Carrera" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 18, 2004 11:22 AM
Subject: [PHP] Is this possible ?


Hi List,

I have a function that makes a call to mysql based on certain vars.

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");  $returnsomething ="blah blah";  }  return $returnsomething; }

And that all works fine no probs here but.....

I want to use a result somewhere in my script that is not returned by
return. Let me show you...

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");

 $num = mysql_num_rows($sql); // I want to use this result outside this
function.

$returnsomething ="blah blah";
 }
 return $returnsomething;
}

So $num contains a number that I want to use outside the function which is
not covered by return.

I know return stops a script and returns what I want it to return but how do
I send out of the function the var I want.

I have tried $GLOBAL[var]=$num; but that don’t work, but I thought I
would'nt anyway just tried it and yes I know I have to declare it inside my
new function using global $var; to use it.

So I ask is this achiveable or how can I do this.

Thank you in advance

Dave C


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004
 

--- End Message ---
--- Begin Message ---
Hi Again,

Fixed it.

Took my code inside the function that needed to return two vars / values for
use and made it a standard if else statement.

Amended other areas and all works as I wanted it.

I would still appreciate comments about what I was trying to do with the
function approach.

Thank you 

Dave C


-----Original Message-----
From: Toby Irmer [mailto:[EMAIL PROTECTED] 
Sent: 18 January 2004 10:29
To: Dave Carrera; [EMAIL PROTECTED]
Subject: Re: [PHP] Is this possible ?


One way:

<?
Function MyFunc()
{
    if(isset($_POST[var])){
        $sql = mysql_query("select * from table_name where
field=\"$_POST[var]\"");

        $num = mysql_num_rows($sql); // I want to use this result outside
this function.

        $returnsomething ="blah blah";
     }
    return array($returnsomething, $num);
}

list($text, $numrows) = MyFunc();
?>

hth

toby

----- Original Message -----
From: "Dave Carrera" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 18, 2004 11:22 AM
Subject: [PHP] Is this possible ?


Hi List,

I have a function that makes a call to mysql based on certain vars.

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");  $returnsomething ="blah blah";  }  return $returnsomething; }

And that all works fine no probs here but.....

I want to use a result somewhere in my script that is not returned by
return. Let me show you...

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");

 $num = mysql_num_rows($sql); // I want to use this result outside this
function.

$returnsomething ="blah blah";
 }
 return $returnsomething;
}

So $num contains a number that I want to use outside the function which is
not covered by return.

I know return stops a script and returns what I want it to return but how do
I send out of the function the var I want.

I have tried $GLOBAL[var]=$num; but that don’t work, but I thought I
would'nt anyway just tried it and yes I know I have to declare it inside my
new function using global $var; to use it.

So I ask is this achiveable or how can I do this.

Thank you in advance

Dave C


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004
 

--- End Message ---
--- Begin Message ---
Toby's solution still holds in this scenario.  Actually exactly has you have
rem'ed out.  You get back two components to the array, first array[0] holds
the concatenated string you made with the while loop and the second array[1]
holds the total number of result rows from your query.

Larry

-----Original Message-----
From: Dave Carrera [mailto:[EMAIL PROTECTED]
Sent: Sunday, January 18, 2004 6:11 AM
To: 'Toby Irmer'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] Is this possible ?


Thanks Toby,

But I forgot to mention something that makes retuning an array not usable in
the context of my needs.

<?
Function MyFunc()
{
    if(isset($_POST[var])){
        $sql = mysql_query("select * from table_name where
field=\"$_POST[var]\"");

                $num = mysql_num_rows($sql); // I want to use this result
outside this function in another function elsewhere.
        While($rows = mysql_fetch_array($sql){

    $returnsomething .="blah blah";
        }
     }
        return $returnsomething;
    // return array($returnsomething, $num); // your suggested answer
}

// list($text, $numrows) = MyFunc(); // Your suggested answer
?>

As you can see with my ammeded example I am already returning and array.

I thought I could cast the result $num into the $GLOBAL array for use later
but that dose not seem to work or be do able.

I could relicate the function and call it something else say MyFunc2() but
that seems a waste of code and mysql connection load when I am already
retrieving the var I want to use.

Any further ideas are appreciated.

Dave C

-----Original Message-----
From: Toby Irmer [mailto:[EMAIL PROTECTED]
Sent: 18 January 2004 10:29
To: Dave Carrera; [EMAIL PROTECTED]
Subject: Re: [PHP] Is this possible ?


One way:

<?
Function MyFunc()
{
    if(isset($_POST[var])){
        $sql = mysql_query("select * from table_name where
field=\"$_POST[var]\"");

        $num = mysql_num_rows($sql); // I want to use this result outside
this function.

        $returnsomething ="blah blah";
     }
    return array($returnsomething, $num);
}

list($text, $numrows) = MyFunc();
?>

hth

toby

----- Original Message -----
From: "Dave Carrera" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 18, 2004 11:22 AM
Subject: [PHP] Is this possible ?


Hi List,

I have a function that makes a call to mysql based on certain vars.

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");  $returnsomething ="blah blah";  }  return $returnsomething; }

And that all works fine no probs here but.....

I want to use a result somewhere in my script that is not returned by
return. Let me show you...

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");

 $num = mysql_num_rows($sql); // I want to use this result outside this
function.

$returnsomething ="blah blah";
 }
 return $returnsomething;
}

So $num contains a number that I want to use outside the function which is
not covered by return.

I know return stops a script and returns what I want it to return but how do
I send out of the function the var I want.

I have tried $GLOBAL[var]=$num; but that don’t work, but I thought I
would'nt anyway just tried it and yes I know I have to declare it inside my
new function using global $var; to use it.

So I ask is this achiveable or how can I do this.

Thank you in advance

Dave C


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Do this:
function MyFunc($num=NULL)
{
if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");

 $num = mysql_num_rows($sql); // I want to use this result outside this
function.

$returnsomething ="blah blah";
 }
 return $returnsomething;
}

$numrows=0;
$res_arr=MyFunc(&$numrows);

Notice the &, that'll make the value of $numrows changed... I did not test
this at all, but it should work.. If you only do MyFunc(); without any
parameters, it'll just return the result of the SQL statement..
-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"Dave Carrera" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
Hi List,

I have a function that makes a call to mysql based on certain vars.

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");
 $returnsomething ="blah blah";
 }
 return $returnsomething;
}

And that all works fine no probs here but.....

I want to use a result somewhere in my script that is not returned by
return. Let me show you...

---example----

Function MyFunc(){
 if(isset($_POST[var])){
 $sql = mysql_query("select * from table_name where field=\"$_POST[var]\"
");

 $num = mysql_num_rows($sql); // I want to use this result outside this
function.

$returnsomething ="blah blah";
 }
 return $returnsomething;
}

So $num contains a number that I want to use outside the function which is
not covered by return.

I know return stops a script and returns what I want it to return but how do
I send out of the function the var I want.

I have tried $GLOBAL[var]=$num; but that don’t work, but I thought I
would'nt anyway just tried it and yes I know I have to declare it inside my
new function using global $var; to use it.

So I ask is this achiveable or how can I do this.

Thank you in advance

Dave C


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004

--- End Message ---
--- Begin Message ---
My hosting company recently upgraded to PHP 4.3.0. Since doing this I no
longer get syntax type errors, from my typo's inside my PHP scripts. These
use to come up in my browser when that page was requested and the script
run.

I have spent hours going through the online help, trying to set a number of
the error reporting levels and parameters  but cannot get to where it will
report on a syntax error.

For example if I code

echo "This is a syntax error because of the double quote start and the
single quote end ';

I just get a blank screen.

I have 14 pages of PHP settings printed out, so for any kind person that can
help, I can respond with their values quickly.

Thanks
Chris Edwards

--- End Message ---
--- Begin Message ---
Chris Edwards wrote:

        [cut]
 
> For example if I code
> 
> echo "This is a syntax error because of the double quote start and the
> single quote end ';
> 
> I just get a blank screen.
> 
> I have 14 pages of PHP settings printed out, so for any kind person that can
> help, I can respond with their values quickly.

        Try putting this at the beginning
 of your script:

 ini_set('display_errors', 1);

-- 
Seks, seksić, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info  { iWanToDie }   WiNoNa    )   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne kształty... http://www.opera.com 007

--- End Message ---
--- Begin Message --- Chris Edwards wrote:
My hosting company recently upgraded to PHP 4.3.0. Since doing this I no
longer get syntax type errors, from my typo's inside my PHP scripts. These
use to come up in my browser when that page was requested and the script
run.

You probably need to have them turn on display_errors (or do so yourself with an .htaccess file, if allowed).


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
I would like to compare strings. I'm using this for my navigation

PSEUDO-CODE

IF $title CONTAINS "abc: def"

        print TITLE;

        print SUB1;
        print SUB2;
        print SUB3;

ELSE

        print TITLE;


Comparing the number of characters in one string with another does not do
the trick. (strcmp)

Is there anything besides a general regex?

Or is my concern about processing speed unwaranted? There would be dozens of
look-ups per page, even using switch-case.

-- gil

--- End Message ---
--- Begin Message ---
Hello mayo,

Sunday, January 18, 2004, 6:06:41 PM, you wrote:

m> I would like to compare strings. I'm using this for my navigation

m> IF $title CONTAINS "abc: def"

m> Comparing the number of characters in one string with another does not do
m> the trick. (strcmp)

If I have understood your pseudo code correctly then you're not really
comparing strings, you're just checking to see if a string contains a
set of characters (i.e. another string).

There is no reason why you couldn't do:

if (strpos($title, "abc: def") === false)
{
   // not found
}
else
{
    // do stuff
}

-- 
Best regards,
 Richard                            mailto:[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
thx Jason

I had overlooked a few functions. My bad. strpos() also works.

thx,

-- gil


 > -----Original Message-----
 > From: Jason Sheets [mailto:[EMAIL PROTECTED]
 > Sent: Sunday, January 18, 2004 1:15 PM
 > To: mayo
 > Subject: Re: [PHP] compare lists
 > 
 > 
 > mayo wrote:
 > 
 > >I would like to compare strings. I'm using this for my navigation
 > >
 > >PSEUDO-CODE
 > >
 > >IF $title CONTAINS "abc: def"
 > >
 > >    print TITLE;
 > >
 > >    print SUB1;
 > >    print SUB2;
 > >    print SUB3;
 > >
 > >ELSE
 > >
 > >    print TITLE;
 > >
 > >
 > >Comparing the number of characters in one string with another 
 > does not do
 > >the trick. (strcmp)
 > >
 > >Is there anything besides a general regex?
 > >
 > >Or is my concern about processing speed unwaranted? There would 
 > be dozens of
 > >look-ups per page, even using switch-case.
 > >
 > >-- gil
 > >
 > >  
 > >
 > Look at strstr
 > 
 > Jason

--- End Message ---
--- Begin Message ---
thx Richard,

wouldn't you know it, you can look for something, can't find it, post a
question, and then find it?

go figure  :-)

thx

-- gil

 > -----Original Message-----
 > From: Richard Davey [mailto:[EMAIL PROTECTED]
 > Sent: Sunday, January 18, 2004 1:26 PM
 > To: mayo
 > Cc: php-general
 > Subject: Re: [PHP] compare lists
 >
 >
 > Hello mayo,
 >
 > Sunday, January 18, 2004, 6:06:41 PM, you wrote:
 >
 > m> I would like to compare strings. I'm using this for my navigation
 >
 > m> IF $title CONTAINS "abc: def"
 >
 > m> Comparing the number of characters in one string with another
 > does not do
 > m> the trick. (strcmp)
 >
 > If I have understood your pseudo code correctly then you're not really
 > comparing strings, you're just checking to see if a string contains a
 > set of characters (i.e. another string).
 >
 > There is no reason why you couldn't do:
 >
 > if (strpos($title, "abc: def") === false)
 > {
 >    // not found
 > }
 > else
 > {
 >     // do stuff
 > }
 >
 > --
 > Best regards,
 >  Richard                            mailto:[EMAIL PROTECTED]
 >
 >

--- End Message ---
--- Begin Message ---
Hey,

Just curious if anyone here would be interested in helping me convert my
PHP Calendar into a class... I am not to good at it... But I figure if
someone would like to do it they could get this nifty calendar program
that I made... Nice little trade... Let me know and I will forward the
code.

Joe

--- End Message ---
--- Begin Message --- Hello,

On 01/18/2004 05:57 PM, Joe Harman wrote:
Just curious if anyone here would be interested in helping me convert my
PHP Calendar into a class... I am not to good at it... But I figure if
someone would like to do it they could get this nifty calendar program
that I made... Nice little trade... Let me know and I will forward the
code.

All you need to do is basically include all the functions and global variables that it uses withing class some_calendar_class { ... }; .


Then change all internal accesses to those functions and variable by preceeding them with $this-> .

If you do not want to go through all this trouble, you may find some calendar classes ready for you here:

http://www.phpclasses.org/browse.html/class/9/top/rated.html

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
ive a problem with php and mysql, and was told to re-compile php. is this
easy?? i got a box with rhl 9 pre-loaded, with php and mysql installed, but
no apache. so i just downloaded the apache binary. php was installed with
rpm i think. to recompile, do ive to uninstall php firs t(u can guess im
used to windows) or will the new compile just overwrite everything.

--
**********************************
    Free Nokia Ringtones US
    http://www.ring-tones.us
**********************************

--- End Message ---
--- Begin Message ---
Hello,

I have done whatever I could to send messages to
newsgroups but messages do not appear in the list (I
think server ignores them).

I have set a valid email and I am using XanaNews
client.

I really hate to receive huge amounts of emails in my
box from listserver (as I am forced now).

Any solution?

Mac

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

--- End Message ---
--- Begin Message ---
Hello,

1- Would someone please tell me if it is possible to
run OOP codes written for PHP4 on PHP5 yet? Or we need
to change codes?

2- Also what should we do? Continue with developing
OOP codes for PHP4 or wait for PHP5 to appear on
hosting servers (mostly using redhat distros) and then
develop for them or what?

What is your strategy?

Regards,
Mac


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

--- End Message ---
--- Begin Message --- SASSINC Internet Solutions - Arabic Department wrote:

I want to make a PHP page that reads from a mySQL Database.. This page displays two fields for the user : 1- Username. 2- Password.

Now in the database there are many columns.. each one has many fields :

Username, Password, Serial, Phone No., Address..Etc..

Now I want the PHP file to take the Username and Password after the user enter them in the fields and compare them with the ones inside the database.. if they are the same.. the serial field inside the database will send its value to the PHP page.. which will echo it as a variable ($var) there..




Ok, here goes a crazy experiment:

Agreement:

To read and use the code below, you must first send $50 via paypal to the email address this message came from.

The following code is untested and may have errors, if the $50 shows up via pay pal I will help fix any errors this code may have.

Login.html:

<HTML>
<HEAD>
<SCRIPT>
function selectit() {
  document.forms["Login"].elements["UserName"].focus();
}
</SCRIPT>
</HEAD>
<BODY>
 <form NAME="Login" ACTION="/Login.php" METHOD="POST">
   <B>Log In:</B><BR>
   User Name:
   <input TYPE="TEXT" SIZE="17" MAXLENGTH="16" NAME="UserName"><br>
   Password:
   <input TYPE="PASSWORD" SIZE="17"MAXLENGTH="16" NAME="Password"><br>
   <input TYPE="SUBMIT" NAME="SUBMIT" VALUE="Log In"><br>
 </FORM>
</BODY></HTML>

Login.php
<?php

$link = mysql_connect($MySQLHost, $MySQLUser, $MySQLPass) or die("Could not connect: " . mysql_error());
mysql_select_db("dbname", $link);


$UserName = stripslashes($_POST['UserName']);
$Password = stripslashes($_POST['Password']);

$User = mysql_real_escape_string(trim($UserName));
$query = "SELECT Serial, Password from user where UserName='$User'";
$result = mysql_query($query) or die("Query errort: " . mysql_error());
$row = mysql_fetch_row($result) or die("User Not found: " . mysql_error());
$Serial = htmlspecialchars($row[0]);
$UserPassword = $row[1];
mysql_close($link);

if($UserPassword == $Password){
 print<<<END
<HTML>
<BODY>
Serial: $Serial
</BODY></HTML>
END;

}else{
 print<<<END
<HTML>
<BODY>
Sorry, wrong password!
</BODY></HTML>
END;
}
?>

--- End Message ---

Reply via email to