Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
<?php
$servername = 'localhost';
$username = 'root';
$password = 'helloworld';
$dbname = 'campus';

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
ini_set('display_errors', 1);
error_reporting(E_ALL);
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$adminuser = $_POST["textname"];
$adminpass = $_POST["pass"];
$sql = "SELECT name,password FROM admin where name='$adminuser' and password='$adminpass';";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0)
{
echo "Welcome $adminuser
" ;
$sql2 = "SELECT * FROM company;";
$result2 = mysqli_query($conn, $sql2);
if(mysqli_num_rows($result2))
{
echo "table, th, td {
border: 1px solid black;" ;
echo "" ;
//echo "" ;
echo "Company Details" ;
echo "" ;
echo "
" ;
while($row = mysqli_fetch_assoc($result2))
{
echo "" ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "  
" ;
}
echo "" ;
echo "
Name
Name Post Job Salary GPA Email
  " . $row["name"] . "   " . $row["post_job"] . "  " . $row["salary"] . "  " . $row["eligibility_criteria"] . "  " . $row["email"] . "  
" ;
echo "










" ;
$sql3 = "SELECT * from students ;" ;
$result3 = mysqli_query($conn,$sql3);
if(mysqli_num_rows($result3))
{
echo "table, th, td {
border: 1px solid black;
}" ;
echo "Student Details
" ;
echo "                                            
" ;
echo "" ;
while($row = mysqli_fetch_assoc($result3))
{
echo "   " ;
//echo "" ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "   " ;
echo "  
" ;
}
echo '' ;
echo '
NAMEMOB.NOGENDEREMAILPREF.LOCADDRESSSSLCHSCCGPALANGUAGESINTERNSHIPSAPPLIED JOB
" . $row["name"] . "  Mobile No" . $row["mobile_no"] . "  " . $row["gender"] . "  " . $row["email"] . "  " . $row["preferred_loc"] . "  " . $row["address"] . "  " . $row["sslc"] . "   " . $row["hsc"] . "   " . $row["cgpa"] . "   " . $row["languages"] . "   " . $row["internships"] . "   " . $row["applied_job"] . "  
' ;
echo "LOGOUT";
}
}
}
else
{
echo "Invalid username or password" ;
echo "BACK" ;
}
mysqli_close($conn);
?>

What I have tried:

I need it fro my school mini project
Posted
Updated 9-Jun-18 3:27am

PHP and Perl are two completely different beasts. And as it is a school project you should do your own homework, rather than expecting someone else to do it for you.
 
Share this answer
 
PHP
$sql = "SELECT name,password FROM admin where name='$adminuser' and password='$adminpass';";

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900