Tweet Follow @LawBlogger1   

Advertisments:


Sponsor Links:

Bar Exam Flashcards
Discount Legal Forms
Discounted Legal Texts

Help, i want the html and php code, for showing a website if the user and pass are correct?

  
Tweet

Help, i want the html and php code, for showing a website if the user and pass are correct?

Postby bothan » Mon Apr 30, 2012 10:16 pm

i m newbie in this ... i want to create something that you sign in with a username and password and if they are correct as they are in myphpMyAdmin server, then it will allow you the access to an website, it will show you a website.

here are html and php files that i copy them from an other thing.It is a form that you put a flight num and shows you the details. Pls make the changes so this will work as i descripted above.

html:
<div id="form">

<form action="apartmentsearch.php" method="post">
<p class="pr">
Apartment ID:<input type="text" name="FlightCode" />
<input type="submit" value="search"/>
</form>
</div>

and php:

<?php

// Use your own connection details
$db_hostname = '***';
$db_username = '***';
$db_password = '***';
$db_database = '***';

// Do not change anything
$connection = mysql_connect($db_hostname, $db_username, $db_password);

if (!$connection) die("Unable to connect to MySQL: " . mysql_error());

// this is a message for successful connection
echo "Connection to ".$db_hostname." as user ".$db_username." succesful!! <br/><br/>";

mysql_select_db($db_database) or die("Unable to select database: " . mysql_error());
// this is a message for successful database selection
echo "Selection of database ".$db_database." succesful as well!! <br/><br/>";

// Get the flight code from the input form
$FlightCode = $_POST["FlightCode"];
echo 'Your input is '.$FlightCode.'<br/><br/>';

// Create the query
$query = "SELECT FlightNumber, Departure, Destination, DepartureDate, DepartureTime FROM Flights ";
if ($FlightCode != '') $query = $query."WHERE FlightNumber ='$FlightCode'";

// show the query
echo $query.'<br/><br/>';

// Execute query
$result = @mysql_query($query, $connection);

// This is the message in case of unsuccesful query execution
if (!$result) die("<br/>SEARCH failed: $query" . mysql_error());

$rows = mysql_num_rows($result);
// show the results
// adapt the following according to your database schema
for ($j = 0 ; $j < $rows ; ++$j){
echo 'FlightNumber: ' . mysql_result($result,$j,'FlightNumber') . '';
echo 'Departure: ' . mysql_result($result,$j,'Departure') . '';
echo 'Destination: ' . mysql_result($result,$j,'Destination') . '';
echo 'DepartureDate: ' . mysql_result($result,$j,'DepartureDate') . '';
echo 'DepartureTime: ' . mysql_result($result,$j,'DepartureTime') . '';
}
// Close the connection to the database server
mysql_close($connection);
?>
</body>
</html>
bothan
 
Posts: 2
Joined: Thu Mar 31, 2011 3:30 pm
Top

Return to Class Action

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest