This script works on my localhost but not on my server

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

Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

Code: Select all

<?php 

session_start(); 

session_register('auth'); 

session_register('logname'); 

include("dogs.inc"); 

switch (@$do) 

{ 

   case "login"; 

     $connection = mysql_connect($host ,$user,$password) 

             or die ("<font face='verdana' color='#e1e1e1' size='1'>Couldn't connect to server1."); 

     $db = mysql_select_db($database, $connection) 

             or die ("<font face='verdana' color='#e1e1e1' size='1'>Couldn't connect to server2."); 



     $sql = "SELECT loginName FROM member 

             WHERE loginName='$logname'"; 

     $result = mysql_query($sql) 

             or die ("<font face='verdana' color='#e1e1e1' size='1'>Couldn't connect to server3."); 

     $num = mysql_num_rows($result); 

     if ($num == 1)  // login name was found 

     { 

        $sql = "SELECT loginName FROM member 

          WHERE loginName='$fusername' 

          AND password=password('$fpassword')"; 

     $result2 = mysql_query($sql) 

            or die("<font face='verdana' color='#e1e1e1' size='1'>Couldn't execute query4."); 

     $num2 = mysql_num_rows($result2); 

     if ($num2 > 0) // password is correct 

     { 

       $auth="yes"; 

       $logname=$fusername; 

       $today = date("d-m-y h:m:s"); 

       $sql = "INSERT INTO Login (loginName,loginTime) 

               VALUES ('$logname','$today')"; 
               $message="<font face='verdana' color='#e1e1e1' size='1'>Thank you for loging in"; 

       mysql_query($sql) or die("<font face='verdana' color='#e1e1e1' size='1'>Can't execute query.5"); 
       $message = "<font face='verdana' color='#e1e1e1' size='1'>$fusername you are now being logged in. Thank You"; 
       header("location: members_page.php"); 

     } 

     else    // password is not correct 

     { 

       unset($do); 

       $message="<font face='verdana' color='#e1e1e1' size='1'>The Login Name, '$fusername' exists, 

                 but you have not entered the correct 

                 password! Please try again.<br>"; 

       include("login_form.inc"); 

     } 

    } 

    elseif ($num == 0) //login name not found 

    { 

       unset($do); 

       $message = "<font face='verdana' color='#e1e1e1' size='1'>The login name you entered does not 

                   exist!Please try again.<br>"; 

       include("login_form.inc"); 

    } 

    break; 



    case "new": 
         /*check to see is login name already exists*/ 

         $connection = mysql_connect($host, $user,$password) 

                       or die ("Couldn't connect to server1."); 

         $db = mysql_select_db($database, $connection) 

                       or die ("Couldn't connect to database1."); 

         $sql = "SELECT loginName FROM member 

                 WHERE loginName='$newname'"; 

         $result = mysql_query($sql) 

                       or die("Couldn't execute query6."); 

         $num = mysql_numrows($result); 

         if ($num > 0) 

         { 

            unset($do); 

            $message_new = "<font face='verdana' color='#e1e1e1' size='1'>$newname already used. Select another 

                            Member ID."; 

            include("login_form.inc"); 

            exit(); 

         } 

         else 

         { 

            $today = time("Y-m-d"); 
            $sql = "INSERT INTO member (loginName,password, 

                     email) VALUES 

                    ('$newname',password('$newpass'),'$email')"; 

            mysql_query($sql); 

            $auth="yes"; 

            
            

         } 

         break; 



         default: 

             include("login_form.inc"); 

} 

?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

show me login_form.inc

Mark
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

oh ok,

its for a game i play, a list of scammers people can add to.

Code: Select all

<?php

 include("dogs.inc");

?>

<html>
<font face ="verdana" color="#e1e1e1" size="1">

<head><title>Add a Scammer</title></head>

<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#000055">  

 <tr>













     <p><font face="verdana" color="#e1e1e1" size="1">To use the database add a Scammer in the bow below and hit enter.</b>

  <!-- form for new member to fill in -->

  <form action="Login.php?do=new" method="post">

  <p>

  <table border="0" width="50%">

   <?php

     if (isset($message_new))

            echo "<tr><td colspan='2'><b>$message_new</b></td></tr>";

   ?>

   <tr><td><b><font face="verdana" color="#e1e1e1" size="1">RWK User Name</b></td>

    <td><input type="test" name="newname"

              value="<?php echo @$newname ?>"

              size="20" maxlength="20"></td></tr>



   <tr><td>&nbsp;</td>

    <td width="50%">

      <input type="submit" value="Add The Scammer"></td>

   </tr>

  </table>

  </form>

 </td> 

 </tr>

 <tr><td colspan="3" bgcolor="e1e1e1">&nbsp;</td></tr>

</table>

<div align="center"><font size="2" color="e1e1e1" face="verdana">
<br><br>
<a href="members_page.php"><font size="2" color="e1e1e1" face="verdana"><b>View the SCAMMER list<b></a>
<br><br>
<font size='1'>

Script created by Kyias Shadow  (Steven Church)<br>
<br>If you find a bug please PM me

</font></div>

</body>
?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

try this, see what you get

Code: Select all

<?php 

session_start(); 

session_register('auth'); 

session_register('logname'); 

include("dogs.inc"); 

$do = $_GET['do'];
$newname = $_POST['newname'];

switch (@$do) 

{ 

   case "login"; 

     $connection = mysql_connect($host ,$user,$password) 

             or die ("<font face='verdana' color='#e1e1e1' size='1'>Couldn't connect to server1."); 

     $db = mysql_select_db($database, $connection) 

             or die ("<font face='verdana' color='#e1e1e1' size='1'>Couldn't connect to server2."); 



     $sql = "SELECT loginName FROM member 

             WHERE loginName='$logname'"; 

     $result = mysql_query($sql) 

             or die ("<font face='verdana' color='#e1e1e1' size='1'>Couldn't connect to server3."); 

     $num = mysql_num_rows($result); 

     if ($num == 1)  // login name was found 

     { 

        $sql = "SELECT loginName FROM member 

          WHERE loginName='$fusername' 

          AND password=password('$fpassword')"; 

     $result2 = mysql_query($sql) 

            or die("<font face='verdana' color='#e1e1e1' size='1'>Couldn't execute query4."); 

     $num2 = mysql_num_rows($result2); 

     if ($num2 > 0) // password is correct 

     { 

       $auth="yes"; 

       $logname=$fusername; 

       $today = date("d-m-y h:m:s"); 

       $sql = "INSERT INTO Login (loginName,loginTime) 

               VALUES ('$logname','$today')"; 
               $message="<font face='verdana' color='#e1e1e1' size='1'>Thank you for loging in"; 

       mysql_query($sql) or die("<font face='verdana' color='#e1e1e1' size='1'>Can't execute query.5"); 
       $message = "<font face='verdana' color='#e1e1e1' size='1'>$fusername you are now being logged in. Thank You"; 
       header("location: members_page.php"); 

     } 

     else    // password is not correct 

     { 

       unset($do); 

       $message="<font face='verdana' color='#e1e1e1' size='1'>The Login Name, '$fusername' exists, 

                 but you have not entered the correct 

                 password! Please try again.<br>"; 

       include("login_form.inc"); 

     } 

    } 

    elseif ($num == 0) //login name not found 

    { 

       unset($do); 

       $message = "<font face='verdana' color='#e1e1e1' size='1'>The login name you entered does not 

                   exist!Please try again.<br>"; 

       include("login_form.inc"); 

    } 

    break; 



    case "new": 
         /*check to see is login name already exists*/ 

         $connection = mysql_connect($host, $user,$password) 

                       or die ("Couldn't connect to server1."); 

         $db = mysql_select_db($database, $connection) 

                       or die ("Couldn't connect to database1."); 

         $sql = "SELECT loginName FROM member 

                 WHERE loginName='$newname'"; 

         $result = mysql_query($sql) 

                       or die("Couldn't execute query6."); 

         $num = mysql_numrows($result); 

         if ($num > 0) 

         { 

            unset($do); 

            $message_new = "<font face='verdana' color='#e1e1e1' size='1'>$newname already used. Select another 

                            Member ID."; 

            include("login_form.inc"); 

            exit(); 

         } 

         else 

         { 

            $today = time("Y-m-d"); 
            $sql = "INSERT INTO member (loginName,password, 

                     email) VALUES 

                    ('$newname',password('$newpass'),'$email')"; 

            mysql_query($sql); 

            $auth="yes"; 

            
            

         } 

         break; 



         default: 

             include("login_form.inc"); 

} 

?>
Mark
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

ok ill brb in 20 i need to reboot then smash my computer up, damn the creators *programmors* of XP need shooting
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

ok it fooked, it still doesnt add nothing to the database,

http://www.schurch.valcatohosting.com/Scammers

try using it, i cant get it to work, when you add a name it goes to a cannot find.... page then click back and view the full scammers list.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

this might sound simple but its happened to me a few times, have you made sure the link is correct back down to the verification page for eg

postpage.php <-- the page that you fill out the spammers info and it redirects to say scripts/posthandle.php then to redirect you when its done ../thankyou.php

this isnt the problem right?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

change the case of the filename.

THe actual filename is login.php but you are calling Login.php

Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

lol, what a legend
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

YES!!! if i could come round the whole of UK today id hug you all :( you all up north tho lol
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Does it work then?


Mark
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

yeah it works, but i have another question once you enter a name it trakes you to a page saying you have added a scammer, how do i get it to tell the user what name he has just entered?

i apreciate all the help guys/gals
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

Code: Select all

print $_POST['scammer_name']
// scammer name being the name of the text field in the form
// and POST begin the form method
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

i thought i would add the reason that it wouldnt work before:

i am guessing that you are using windows

filenames are not case-sensitive in windows, in linux they are

it is good practice to always use lower-case
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

ok,

It worked a ok but <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> that play the game i play abused teh system spamming it with a bunch of Shi* so i need to restrict the login.php page for people that a trustworthy to add names, how may i do this? anyone have any ideas? using a <script> promp box asking for a password messis around iwth the script firing errors at me.
Post Reply