You are here: Re: PLEASE HELP ME ($20 REWARD!!) PHP(v5.0.4)/MySQL(v4.1.14) Problem. Need Basic Drop-down menu populated by 1 column from MySql « PHP Programming Language « IT news, forums, messages
Re: PLEASE HELP ME ($20 REWARD!!) PHP(v5.0.4)/MySQL(v4.1.14) Problem. Need Basic Drop-down menu populated by 1 column from MySql

Posted by snowsong1 on 01/26/06 08:51

Thank you very much for the help, NC.
It has helped me a long quite a bit, as I now see the house names
populating the drop-down list.

The only problem i have is that I need a password blank below it to
submit passwords, and everything I have tried to combine my previous pw
blank with this drop down list doesn't work.
Sorry, I'm a php novice in way over my head.
Could you please tell me how to add a pw blank? I have attached my
code below if it helps, with what you helped me do inserted.

Thank you very much,

Sincerely,

Jamie


<?php // greek login
// Send NOTHING to the Web browser prior to the setcookie() lines!

// Check if form submitted.
if (isset($_POST['submitted'])) {

require_once ('./lcr_folder/mysql_connect.php'); // Connect to the db.

$errors = array(); // Init error array


// Check for HOUSE
if (empty($_POST['house'])) {
$errors[] = 'You forgot to enter your HOUSE name.';
} else {
$gk_h = ($_POST['house']);
}

// Check for PW
if (empty($_POST['greek_password'])) {
$errors[] = 'You forgot to enter your password.';
} else {
$p = ($_POST['greek_password']);
}

if (empty($errors)) { // If everything's ok

// Retrieve the info to go in email/pw combo
$query = "SELECT greek_id, house, gk_phone, greek_email FROM greeks
WHERE house='$gk_h' AND greek_password=SHA('$p')";
$result = @mysql_query ($query); // Run query
$row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record if
applicable.

if ($row) { // A record was pulled from the database.

// Set the cookies & redirect.
setcookie ('greek_id', $row[0]);
setcookie ('house', $row[1]);
setcookie ('gk_phone', $row[2]);
setcookie ('greek_email', $row[3]);
// Redirect the user to the loggedin.php page.
// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] .
dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
// Add the page.
$url .= '/gk_loggedin.php';

header("Location: $url");
exit(); // Quit the script.

} else { // No record matched the query.
$errors[] = 'The house name and password entered do not match those
on file.'; // Public message.
$errors[] = mysql_error() . '<br /><br />Query: ' . $query; //
Debugging message.
}

} // End of if (empty($errors)) IF.

mysql_close(); // Close the database connection.

} else { // Form has not been submitted.

$errors = NULL;

} // End of the main Submit conditional.

// Begin the page now.
$page_title = 'Greek Login';
include ('./lcr_folder/header.html');

if (!empty($errors)) { // Print any error messages.
echo '<h1 id="mainhead">Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg) { // Print each error.
echo " - $msg<br />\n";
}
echo '</p><p>Please try again.</p>';
}
?>




<?php
// Create the form.
require_once ('./lcr_folder/mysql_connect.php');

// Performing SQL query
$result = mysql_query('SELECT house FROM greeks')
or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<form action='#' method='post'>\r\n<select name=house>\r\n";
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
$house = $line[0];
echo "<option value=$house>$house\r\n";
}
echo "</select>\r\n <input type=submit value=Send>\r\n</form>\r\n";
?>

<! THIS STUFF IS WHAT I USED BEFORE. I was able to log in by typing
user names and passwords manually -->
<! Now I would like to be able to combine the password blank below
(drop the House Name blank, of course) -->
<form action="gk_login.php" method="post">
<p>Greek House Name: <input type="text" name="house" size="20"
maxlength="40" /> </p>
<p>Greek Password: <input type="password" name="greek_password"
size="20" maxlength="20" /></p>
<p><input type="submit" name="submit" value="Login" /></p>
<input type="hidden" name="submitted" value="TRUE" />
</form>


<?php
include ('./lcr_folder/footer.html');
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация