php-general Digest 16 Sep 2007 21:24:47 -0000 Issue 5022

Topics (messages 262141 through 262149):

php Login script issue
        262141 by: Chris Carter
        262142 by: Tijnema
        262146 by: Sanjeev N
        262147 by: Bastien Koert

Re: Configure mail to use Gmail smtp
        262143 by: debussy007
        262144 by: Thomas Bachmann
        262148 by: mike

Re: split in to multiple pages (I think)
        262145 by: Thomas Bachmann

Finding next recored in a array
        262149 by: Richard Kurth

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 ---
Hi,

Its just a login and password validation that I am trying to achieve. If the
username is correct then the person is able to view certain page, if
incorrect then he is directed elsewhere.

<?
$userid=mysql_real_escape_string($userid);
$password=mysql_real_escape_string($password);

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tablename WHERE
userName='$userName' AND password = '$password'"))){
        if(($rec['userName']==$userName)&&($rec['password']==$password)){
         include "../include/newsession.php";
            echo "<p class=data> <center>Successfully,Logged in<br><br>
logout.php  Log OUT  <br><br> welcome.php Click here if your browser is not
redirecting automatically or you don't want to wait. <br></center>";
     print "<script>";
       print " self.location='submit-store-details.php';"; // Comment this
line if you don't want to redirect
          print "</script>";

                                } 
                }       
        else {

                session_unset();
echo "Wrong Login. Use your correct  Userid and Password and Try
<br><center><input type='button' value='Retry'
onClick='history.go(-1)'></center>";
                
        }
?>

I am getting this error when I am using this code:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in thispage.php on line 37
Wrong Login. Use your correct Userid and Password and Try

Why does it show up everytime and whats wrong with mysql_fetch_array(). 

Please advice also if there is some other way available please help me try
that.

Thanks,

Chris
-- 
View this message in context: 
http://www.nabble.com/php-Login-script-issue-tf4450691.html#a12698139
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
On 9/16/07, Chris Carter <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Its just a login and password validation that I am trying to achieve. If the
> username is correct then the person is able to view certain page, if
> incorrect then he is directed elsewhere.
>
> <?
> $userid=mysql_real_escape_string($userid);

Here you call it $userid

> $password=mysql_real_escape_string($password);
>
> if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tablename WHERE
> userName='$userName' AND password = '$password'"))){

and here you call it $userName. If this is the full code, $userName is
not set here, and it would result in query userName='' and mysql_query
will return FALSE, which isn't a valid mysql resource for
mysql_fetch_array.

>        if(($rec['userName']==$userName)&&($rec['password']==$password)){
>         include "../include/newsession.php";
>            echo "<p class=data> <center>Successfully,Logged in<br><br>
> logout.php  Log OUT  <br><br> welcome.php Click here if your browser is not
> redirecting automatically or you don't want to wait. <br></center>";
>     print "<script>";
>       print " self.location='submit-store-details.php';"; // Comment this
> line if you don't want to redirect
>          print "</script>";
>
>                                }
>                }
>        else {
>
>                session_unset();
> echo "Wrong Login. Use your correct  Userid and Password and Try
> <br><center><input type='button' value='Retry'
> onClick='history.go(-1)'></center>";
>
>        }
> ?>
>
> I am getting this error when I am using this code:
>
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
> resource in thispage.php on line 37
> Wrong Login. Use your correct Userid and Password and Try
>
> Why does it show up everytime and whats wrong with mysql_fetch_array().
>
> Please advice also if there is some other way available please help me try
> that.
>
> Thanks,
>
> Chris


I advice you to split the code up in 2 seperate actions, and check for errors.

> if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tablename WHERE 
> userName='$userName' AND password = '$password'"))){

would become:
$result = mysql_query("SELECT * FROM tablename WHERE
userName='$userName' AND password = '$password'") or die
(mysql_error());
// You could also add some checks here with mysql_num_rows for example...
if($rec=mysql_fetch_array($result)){

Tijnema


-- 
If this is a mailing list: DO NOT TOP POST! why?:
http://www.caliburn.nl/topposting.html

Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! ->
http://gpcc.tijnema.info

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

$result = mysql_query("SELECT * FROM tablename WHERE
userName='$userName' AND password = '$password'");
if($rec = mysql_fetch_array($result)){
        //your code
}

Try like this it may solve. It may solve your problem
Don't try to fetch the result from one single line code.

Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan
-----Original Message-----
From: Chris Carter [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 16, 2007 3:10 PM
To: [EMAIL PROTECTED]
Subject: [PHP] php Login script issue


Hi,

Its just a login and password validation that I am trying to achieve. If the
username is correct then the person is able to view certain page, if
incorrect then he is directed elsewhere.

<?
$userid=mysql_real_escape_string($userid);
$password=mysql_real_escape_string($password);

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tablename WHERE
userName='$userName' AND password = '$password'"))){
        if(($rec['userName']==$userName)&&($rec['password']==$password)){
         include "../include/newsession.php";
            echo "<p class=data> <center>Successfully,Logged in<br><br>
logout.php  Log OUT  <br><br> welcome.php Click here if your browser is not
redirecting automatically or you don't want to wait. <br></center>";
     print "<script>";
       print " self.location='submit-store-details.php';"; // Comment this
line if you don't want to redirect
          print "</script>";

                                } 
                }       
        else {

                session_unset();
echo "Wrong Login. Use your correct  Userid and Password and Try
<br><center><input type='button' value='Retry'
onClick='history.go(-1)'></center>";
                
        }
?>

I am getting this error when I am using this code:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in thispage.php on line 37
Wrong Login. Use your correct Userid and Password and Try

Why does it show up everytime and whats wrong with mysql_fetch_array(). 

Please advice also if there is some other way available please help me try
that.

Thanks,

Chris
-- 
View this message in context:
http://www.nabble.com/php-Login-script-issue-tf4450691.html#a12698139
Sent from the PHP - General mailing list archive at Nabble.com.

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

--- End Message ---
--- Begin Message ---
argh! hotmail sucks

I don't see in the script where you are using $_POST / $_GET / $_REQUEST to 
access tha data from the form. Its likely that the example you are following is 
old and uses 'register_globals'. Since register_globals is a huge security hole 
and is not active in any new installations of PHP you need to change your 
script to use the above methods to get the form data. The error you are getting 
is due to the fact that you are not passing in the values to the sql and not 
getting a valid result

Note that the below example fixes your issue but DOES NOT do any validation, 
which you really should do before passing your data to the sql...




$userid=mysql_real_escape_string($_POST['userid']);  
$password=mysql_real_escape_string($_POST['password']); 

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tablename WHERE> 
userName='$userName' AND password = '$password'"))){ 

 if(($rec['userName']==$userName)&&($rec['password']==$password))


bastien



----------------------------------------> Date: Sun, 16 Sep 2007 02:39:57 
-0700> From: [EMAIL PROTECTED]> To: [EMAIL PROTECTED]> Subject: [PHP] php Login 
script issue>>> Hi,>> Its just a login and password validation that I am trying 
to achieve. If the> username is correct then the person is able to view certain 
page, if> incorrect then he is directed elsewhere.>>  
$userid=mysql_real_escape_string($userid);> 
$password=mysql_real_escape_string($password);>> 
if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tablename WHERE> 
userName='$userName' AND password = '$password'"))){> 
if(($rec['userName']==$userName)&&($rec['password']==$password)){> include 
"../include/newsession.php";> echo " Successfully,Logged in> logout.php Log OUT 
 welcome.php Click here if your browser is not> redirecting automatically or 
you don't want to wait. ";> print "";>> }> }> else {>> session_unset();> echo 
"Wrong Login. Use your correct Userid and Password and Try>  
onClick='history.go(-1)'>";>> }> ?>>> I am getting this error when I am using 
this code:>> Warning: mysql_fetch_array(): supplied argument is not a valid 
MySQL result> resource in thispage.php on line 37> Wrong Login. Use your 
correct Userid and Password and Try>> Why does it show up everytime and whats 
wrong with mysql_fetch_array().>> Please advice also if there is some other way 
available please help me try> that.>> Thanks,>> Chris> --> View this message in 
context: http://www.nabble.com/php-Login-script-issue-tf4450691.html#a12698139> 
Sent from the PHP - General mailing list archive at Nabble.com.>> --> PHP 
General Mailing List (http://www.php.net/)> To unsubscribe, visit: 
http://www.php.net/unsub.php>

_________________________________________________________________
Connect to the next generation of MSN Messenger 
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline

--- End Message ---
--- Begin Message ---
I succeeded using the Zend Framework.



debussy007 wrote:
> 
> Hello,
> 
> I have read here : http://www.geekzone.co.nz/tonyhughes/599
> that I can use Gmail as a free SMTP server.
> 
> Is it possible to change the php.ini in order to have this running ?
> 
> I need to specify in some way the following :
> 
> Outgoing Mail (SMTP) Server - requires TLS:   smtp.gmail.com (use
> authentication)
> Use Authentication: Yes
> Use STARTTLS: Yes (some clients call this SSL)
> Port: 465 or 587
> Account Name:         your Gmail username (including '@gmail.com')
> Email Address:        your original isp address ([EMAIL PROTECTED])
> Password:     your Gmail password
> 
> 
> 
> I can see in the php.ini that I can specify the port, smtp server and the
> from.
> 
> But how do I do for he other parameters ?
> 
> Thank you !!
> 

-- 
View this message in context: 
http://www.nabble.com/Configure-mail-to-use-Gmail-smtp-tf4450311.html#a12698490
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
ZF rocks ;)

debussy007 schrieb:
I succeeded using the Zend Framework.



debussy007 wrote:
Hello,

I have read here : http://www.geekzone.co.nz/tonyhughes/599
that I can use Gmail as a free SMTP server.

Is it possible to change the php.ini in order to have this running ?

I need to specify in some way the following :

Outgoing Mail (SMTP) Server - requires TLS:     smtp.gmail.com (use
authentication)
Use Authentication: Yes
Use STARTTLS: Yes (some clients call this SSL)
Port: 465 or 587
Account Name:   your Gmail username (including '@gmail.com')
Email Address:  your original isp address ([EMAIL PROTECTED])
Password:       your Gmail password



I can see in the php.ini that I can specify the port, smtp server and the
from.

But how do I do for he other parameters ?

Thank you !!



--- End Message ---
--- Begin Message ---
i'm quite sure you can't with php's built-in mail() function.

however more advanced modules should support it. look in PEAR, google
for phpmailer, etc. i'm sure there's got to be some. worst case i
think you have all the tools in PHP to make your own anyway.

On 9/16/07, debussy007 <[EMAIL PROTECTED]> wrote:

> debussy007 wrote:
> >
> > Hello,
> >
> > I have read here : http://www.geekzone.co.nz/tonyhughes/599
> > that I can use Gmail as a free SMTP server.
> >
> > Is it possible to change the php.ini in order to have this running ?
> >
> > I need to specify in some way the following :
> >
> > Outgoing Mail (SMTP) Server - requires TLS:   smtp.gmail.com (use
> > authentication)
> > Use Authentication: Yes
> > Use STARTTLS: Yes (some clients call this SSL)
> > Port: 465 or 587
> > Account Name:         your Gmail username (including '@gmail.com')
> > Email Address:        your original isp address ([EMAIL PROTECTED])
> > Password:     your Gmail password
> >
> >
> >
> > I can see in the php.ini that I can specify the port, smtp server and the
> > from.
> >
> > But how do I do for he other parameters ?
> >
> > Thank you !!

--- End Message ---
--- Begin Message ---
Why don't post an example of your news file too?

Joker7 schrieb:
Hi,
I'm using the code below to display news articles-which works great apart from. I can control the number of articles,but I would like to add a link to the bottom of the page to the un-displayed articles ( nexted 5 articles and so on) any pointers would be most welcome as most know my PHP skills are not the best :).

Cheers
Chris


<?

  $max_latest = 5;
 $filename = "articlesum.php";

 #- open article
 if(file_exists($filename)){
  $fh = fopen($filename, "r");
  $old_news = fread($fh, filesize($filename));
  fclose($fh);
 }
 #- get article
 $articles = explode("<!--ARTICLE-->", $old_news);

 $i=0;
 foreach ( $articles as $article ){
  if(count($articles)>$i){
   if($max_latest >= $i++){
    print $article;
   }
  }
 }

?>

--- End Message ---
--- Begin Message ---
$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I do not understand is if I know the last number was say 5 how do I tell the script that that is the current number so I can select the next record
||

--- End Message ---

Reply via email to