Jump to content

Passing arguments to new page


vinaykr

Recommended Posts

Hi,

 

I am trying to display a variable that is supposedly created in a different page. Here is the code. But it is not displaying in the next page:

 

ADMIN_login.PHP - Page URL

 

<form name="form2" action="admin_login_success.php" method="post">

<?php

$host="localhost"; // Host name

$username=""; // Mysql username

$password=""; // Mysql password

$db_name="test"; // Database name

$tbl_name="masterschoolinfo"; // Table name

 

// Connect to server and select databse.

mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

// username and password sent from form

$myusername=$_POST['adminusername'];

$mypassword=$_POST['adminpassword'];

 

// To protect MySQL injection (more detail about MySQL injection)

$myusername = stripslashes($myusername);

$mypassword = stripslashes($mypassword);

$myusername = mysql_real_escape_string($myusername);

$mypassword = mysql_real_escape_string($mypassword);

 

$sql="SELECT * FROM $tbl_name WHERE school_username='$myusername' and school_password='$mypassword'";

$result=mysql_query($sql);

 

// Mysql_num_row is counting table row

$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row

 

if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"

session_register("myusername");

session_register("mypassword");

header("location:Admin_login_success.php");

}

else {

header( 'Location: Adminportal.PHP' ) ;

}

?>

</form>

 

admin_login_success.php - Next page where the variable is to be displayed based on the username provided in the above page:

 

<html><body>

<?php

include 'mysql-connect.php';

 

 

$schoolID=mysql_query("select SCHOOLID from masterschoolinfo WHERE school_username='$myusername' and school_password='$mypassword'") or die(mysql_error());

while($row = mysql_fetch_array( $schoolID )) {

 

// Print out the contents of each row into a table

echo "<tr><td>";

echo $row['SCHOOLID'];

echo "</td></tr>";

}

?>

</body></html>

 

CAN SOMEONE HELP ME??

Link to comment
Share on other sites

The structure of the page is off.  I would also NEVER store password in session.

<?php 
session_start();
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="masterschoolinfo"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
$myusername=$_POST['adminusername'];
$mypassword=$_POST['adminpassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE school_username='$myusername' and school_password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['myusername']=$myusername;
//I would NOT EVER use passwords as a variable or session outside of login.
//session_register("mypassword");
header("location:Admin_login_success.php");
}
else {
header( 'Location: Adminportal.PHP' ) ;
}
?>

Link to comment
Share on other sites

Sorry, the code dint helped.

 

 

Deprecated: Function session_is_registered() is deprecated in C:\wamp\www\Admin_login_success.php on line 7

Call Stack

# Time Memory Function Location

1 0.0006 370424 {main}( ) ..\Admin_login_success.php:0

session not regisetered

Link to comment
Share on other sites

admin_login_success.php - Next page where the variable is to be displayed based on the username provided in the above page:

 

<html><body>

<?php

include 'mysql-connect.php';

 

 

$schoolID=mysql_query("select SCHOOLID from masterschoolinfo WHERE school_username='$myusername' and school_password='$mypassword'") or die(mysql_error());

while($row = mysql_fetch_array( $schoolID )) {

 

// Print out the contents of each row into a table

echo "<tr><td>";

echo $row['SCHOOLID'];

echo "</td></tr>";

}

?>

</body></html>

Link to comment
Share on other sites

Drummin, I am totally freaked out here!...

 

Can we be on skype so that I can share my screen with you. I am getting the answer but it is wrong school ID. If this is not against this forum. I dont want to break rules. But I am really really freaked out by looking at my code  :wtf:

 

I will later post the result here

 

 

It should be schoolID=21, but it is displaying as 15..

 

 

:o>:( :'( :wtf:

Link to comment
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.