Jump to content

Little Help in Php


Petite-Dragon

Recommended Posts

im having trouble inserting the <script> code in the die

 

here is my code

 

 

<?php

 

session_start ();

 

 

 

  $username = $_POST ['username'];

  $password = $_POST ['password'];

 

  

  

  if ($username&&$password)

  {

  $connect = mysql_connect ("localhost","root","") or die("Error");

  mysql_select_db('thesis') or die("Error");

  

  $query = mysql_query("SELECT * FROM student WHERE username ='$username'");

  $numrows = mysql_num_rows($query);

 

$query1 = mysql_query("SELECT * FROM admin WHERE username='$username'");

$row1 = mysql_fetch_assoc($query1);

$adusername = $row1['username'];

$adpassword = $row1['password'];

 

$queryid = mysql_query("SELECT id FROM student WHERE username ='$username'");

$row2 = mysql_fetch_assoc($queryid);

$id = $row2['id'];

 

 

if ($username==$adusername&&$password==$adpassword)

{

die(strval($_SESSION['username']=$username));

 

 

die ('<script type="text/javascript">

alert("Welcome Administrator !");

window.location = "adminpage.php";

</script>');

 

}

 

 

 

  if ($numrows!=0)

  {

  while ($row = mysql_fetch_assoc($query))

  {

  

  $dbusername = $row['username'];

  $dbpassword = $row['password'];

  

  }

  

  

if ($username==$dbusername&&$password==$dbpassword)

{

 

echo '<script type="text/javascript">

alert("Login Successful !");

window.location = "studhome.php";

</script>';

$_SESSION['username']=$username;

$_SESSION['id']=$id;

$_SESSION['name']=$name;

 

}

else

echo '<script type="text/javascript">

alert("Incorrect Password !");

window.location = "Login.php";

</script>';

 

}

else 

die('<script type="text/javascript">

alert("User not Registered !");

window.location = "Login.php";

</script>');

 

  }

else

die('<script type="text/javascript">

alert("Please Enter Username/Password !12121");

window.location = "Login.php";

</script>');

 

?>

 

advance thanks

Link to comment
https://forums.phpfreaks.com/topic/294261-little-help-in-php/
Share on other sites

It may help if you provide more information on what you are hoping to do.

 

For what it's worth, only the first call to the die() function will be executed. The second call never gets executed since die() terminates the PHP script. More information can be found here:

http://php.net/manual/en/function.die.php

Link to comment
https://forums.phpfreaks.com/topic/294261-little-help-in-php/#findComment-1504356
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.