Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.