Not able to login through my hosted php page..!!

Morningdot Hablu

Morningdot Hablu

@morningdot-6Xuj4M Oct 22, 2024
Hello friends,
I am trying host my code in a hosting site #-Link-Snipped-# My code is working fine with my pc but not when i hosted there....Look at this code...

<html>
<body bgcolor="green">

<?php
$conn=mysql_connect("https://www.my3gb.com/phpmyadmin/","username","password");
mysql_select_db("mohit007kumar00_cboy",$conn);
print "<h1>connected</h1>";
$rs=mysql_query("select * from signup where user='".$_POST['t1']."'");
print "<h1>queried</h1>";
while($row=mysql_fetch_array($rs))
{
    print "<h1>under while</h1>";
    if($row['pswd']==$_POST['t2'])
    {
        print "<h1>You are alowed</h1>";
    }
    else
    {
        print "<h1>not alowed</h1>";
    }
}
?>
</body>
</html>
and the login page is .....
 <html>
    <body bgcolor="yellow">
    <center>
    <h1>Login Application</h1>
    <form action="log.php" method="post">
    user<input type="text" name="t1"><br><br>
    pswd<input type="password" name="t2"><br><br>
    <input type="submit">
    </form>
    </center>
    </body>
 </html>
on my pc it will show the output like this.... "connected queried under while You are alowed".
But on my hosted link it will show the output like this...... "connected queried".
Can anyone help me to fix this issue...!!

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Apr 4, 2011

    $conn=mysql_connect("https://www.my3gb.com/phpmyadmin/","username","password");
    This line of code might be creating problem for you?


    Make sure that it is working
  • slashfear

    slashfear

    @slashfear-tSWzpz Apr 4, 2011

    Hey mohit,

    Change the host name in the connection string as localhost or with the DNS name of the database, because your running the script in the server (where the database is available) so no need of specifying the full url of the host in that machine. That should fix the problem!!

    Hope that helps!! 😉

    -Arvind
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Apr 4, 2011

    Not sure about this but you may map the domain name to localhost through hosts file? [ Someone correct me please ]
  • Prasad Ajinkya

    Prasad Ajinkya

    @prasad-aSUfhP Apr 4, 2011

    The_Big_K
    Not sure about this but you may map the domain name to localhost through hosts file? [ Someone correct me please ]
    Err, Biggie,
    If the script is running on a shared hosting space like my3gb, then the localhost would refer to that current server and not your machine. I am sure you will not even have access to the server's host file. And the clients host file is pretty much irrelevant in this case
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Apr 4, 2011

    Oops - I meant if the testing is being done on the local server, then windows (desktop) hosts file can be edited to simulate the actual server environment. 😐
  • eternalthinker

    eternalthinker

    @eternalthinker-Kvsi5Y Apr 5, 2011

    Umm.. the script returns no error even on querying the database.. so this would mean that the connection is established smoothly.

    The program is just not entering the while loop. Are you sure the database at the remote host is populated with proper values?
    You can see that the script wouldn't go into the loop in case we entered a non-existent username.

    Try checking if the result set is null with something like:

    if(!$rs) 
        echo "Empty results returned!"
  • Morningdot Hablu

    Morningdot Hablu

    @morningdot-6Xuj4M Apr 5, 2011

    @etk no buddy actually my connection is not established.....you may cehck it by inserting var_dump($rs);
    It will throw the exception caughted.
    Now i got the solution.I have to post DNS name of the database.
    But localhost is not working.
  • slashfear

    slashfear

    @slashfear-tSWzpz Apr 5, 2011

    Ha I was right ok if localhost is not the name then find the DNS name I am sure you will have an access to the mysql server so connect to the server and then you can execute query

    select user();

    which will give the username and the hostname for example : root@localhost

    where root is the user name and after the @ sign is the DNS name 😉

    -Arvind