
natsu
Members-
Posts
25 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
natsu's Achievements

Newbie (1/5)
0
Reputation
-
How to specifiy 2 varaible's for login php using mysql
natsu replied to natsu's topic in PHP Coding Help
nvm, I got it working -
How to specifiy 2 varaible's for login php using mysql
natsu replied to natsu's topic in PHP Coding Help
It's still not working Here is the HTML on the same page (in first post too) <form method='post' action='login.php'> <table><tr><td>Email Address:</td><td><input type='text' name='emailAddress'></td></tr> <tr><td>Password:</td><td><input type='password' name='password'></td></tr> <tr><td></td><td><input type='submit' name='submit' value='Log in'></td></tr></table> </form> The emailAddress and password was made using this on my createAccounte.php <?php require "connectionInfo.php"; $error = ""; if(!isset($_POST["personId"]) || !isset($_POST["firstName"]) || !isset($_POST["lastName"]) || !isset($_POST["emailAddress"]) || !isset($_POST["telephoneNumber"]) || !isset($_POST["socialInsuranceNumber"]) || !isset($_POST["password"]) ) { $error = "Please fill in the info"; } else { if($_POST["personId"] != "" && $_POST["firstName"] != "" && $_POST["lastName"] != "" && $_POST["emailAddress"] != "" && $_POST["telephoneNumber"] != "" && $_POST["socialInsuranceNumber"] != "" && $_POST["password"] != "") { $dbConnection = mysql_connect($host, $username, $password); if(!$dbConnection) die("Could not connect to the database. Remember this will only run on the Playdoh server."); mysql_select_db($database); $sqlQuery = "INSERT INTO persons (FirstName, LastName, EmailAddress, TelephoneNumber, SocialInsuranceNumber, Password) VALUES('".$_POST["firstName"]."', '".$_POST["lastName"]."', '".$_POST["emailAddress"]."', '".$_POST["telephoneNumber"]."', '".$_POST["socialInsuranceNumber"]."', '".$_POST["password"]."');"; if(mysql_query($sqlQuery)) $error = "Person Successfully Added"; else $error = "Person Could not be added : ".mysql_error(); mysql_close($dbConnection); } else $error = "Please enter all the information"; } ?> <form action="createAccount.php" method="post"> Person ID: <input type="text" name="personId" /> <br /> First Name: <input type="text" name="firstName" /> <br /> Last Name: <input type="text" name="lastName" /> <br /> Email: <input type="text" name="emailAddress" /> <br /> Telephone: <input type="text" name="telephoneNumber" /> <br /> Social Insurance Number: <input type="text" name="socialInsuranceNumber" /> <br /> Password: <input type="text" name="password" /> <br /> <input type="submit" value="Submit to Database" /> </form> <br /> <br /> <?php echo $error; ?> -
How to specifiy 2 varaible's for login php using mysql
natsu replied to natsu's topic in PHP Coding Help
what do you mean when u say "whatever name your form login field has", would that be the 'emailAddress' and 'password' -
How to specifiy 2 varaible's for login php using mysql
natsu replied to natsu's topic in PHP Coding Help
This is what I got so far <?php require "connectionInfo.php"; $dbConnection = mysql_connect($host, $username, $password); if(!$dbConnection) die("Could not connect to the database. Remember this will only run on the Playdoh server."); mysql_select_db($lab9_hadd0076); $sqlQuery = "SELECT * FROM persons"; $result = mysql_query($sqlQuery); //$loginDetail = emailAddress, password; How do I specify the login credentials, I know this is wrong if($loginDetail == 0) echo "*** There is no accounts made ***"; else { echo "Yes you have created an account"; } mysql_close($dbConnection); ?> -
Ok so I need to create a form to accept the users EmailAddress and Password as credentials to your site then use an SQL Query to determine if the person has an account <?php require "connectionInfo.php"; $error = ""; if(!isset($_POST["personId"]) || !isset($_POST["firstName"]) || !isset($_POST["lastName"]) || !isset($_POST["emailAddress"]) || !isset($_POST["telephoneNumber"]) || !isset($_POST["socialInsuranceNumber"]) || !isset($_POST["password"]) ) { $error = "Please fill in the info"; } else { if($_POST["personId"] != "" && $_POST["firstName"] != "" && $_POST["lastName"] != "" && $_POST["emailAddress"] != "" && $_POST["telephoneNumber"] != "" &&$_POST["socialInsuranceNumber"] != "" && $_POST["password"] != "") { $dbConnection = mysql_connect($host, $username, $password); if(!$dbConnection) die("Could not connect to the database. Remember this will only run on the Playdoh server."); mysql_select_db($database); $sqlQuery = "INSERT INTO persons (personId, FirstName, LastName, emailAddress, telephoneNumber, socialInsuranceNumber, password) VALUES('".$_POST["personId"]."', '".$_POST["firstName"]."', '".$_POST["lastName"]."', '".$_POST["emailAddress"]."', '".$_POST["telephoneNumber"]."', '".$_POST["socialInsuranceNumber"]."', '".$_POST["password"]."')"; if(mysql_query($sqlQuery)) $error = "Person Successfully Added"; else $error = "Person Could not be added ".mysql_error(); mysql_close($dbConnection); } else $error = "Please enter all the information"; } ?> <form action="createAccount.php" method="post"> Person ID: <input type="text" name="personId" /> <br /> First Name: <input type="text" name="firstName" /> <br /> Last Name: <input type="text" name="lastName" /> <br /> Email: <input type="text" name="emailAddress" /> <br /> Telephone: <input type="text" name="telephoneNumber" /> <br /> Social Insurance Number: <input type="text" name="socialInsuranceNumber" /> <br /> Password: <input type="text" name="password" /> <br /> <input type="submit" value="Submit to Database" /> </form> -----EDIT----- Ok I was able to create the html code for it, but how do I use an sql query to determine if the person has an account? <form method='post' action='login.php'> <table><tr><td>Email Address:</td><td><input type='text' name='emailAddress'></td></tr> <tr><td>Password:</td><td><input type='password' name='password'></td></tr> <tr><td></td><td><input type='submit' name='submit' value='Log in'></td></tr></table> </form>
-
I solved this. Thanks a lot
-
I solved this. Thanks a lot
-
Trying to get 2 per line and into a html table what I have so far <?php for ($i = 0; $i <= 9; $i++) { echo "$i  "; } ?>
-
Sorry, but I dont understand what u mean by concentrating the function to the string.
-
Another problem I am having same trouble with scope for displaying max within a function, I tried global and return, and my output is ----> max(Array), it should show 99 <?php $a = array(9, 3, 1, 0, 99, 2, 5, 6, 32, 1, 55); function highestValue () { global $a; echo "The highest value is at index: (insert index), The value at index (insert index) is: max($a)"; } highestValue(); ?> OUTPUT: The highest value is at index: (insert index), The value at index (insert index) is: max(Array) I still don't know the code to display the index also
-
Thank you, I was able to do it <?php echo "The average is " . array_sum($a)/count($a) . "\n"; ?> As for the max and min's I know how to find the actual highest and lowest, but how would u indicate the index of the highest and lowest? <?php $a = array(9, 3, 1, 0, 99, 2, 5, 6, 32, 1, 55); echo max($a); echo "<br>"; echo min($a); ?>
-
Yes I understand scope's now but I am trying to do http://www.phpfreaks.com/forums/index.php?topic=348076.msg1642492#msg1642492
-
Wow that's really interesting! <?php $a = array(9, 3, 1, 0, 99, 2, 5, 6, 32, 1, 55); function getAverage () { global $a; echo "The average is " . array_sum($a) . "\n"; } getAverage(); ?> I tried do divide that number by the amount of value's in the array like the following <?php echo "The average is " . array_sum($a)/11 . "\n"; // try 1 echo "The average is " . array_sum($a) . "\n"; // try 2 echo "array_sum($a)/11" ?> or is there some sort of code that knows how many elements are in the array? And take the array_sum and divide it by that.
-
Ok I am going to tackle this piece by piece... <?php $a = array(9, 3, 1, 0, 99, 2, 5, 6, 32, 1, 55); function getAverage () { echo "The average is " . array_sum($a) . "\n"; } getAverage(); ?> I know that array_sum doesn't return the average, it returns the sum of the array. But even that is not displaying the total why? if I display the following line of code outside the function <?php echo "The average is " . array_sum($a) . "\n"; ?> It works, but if I write it inside the function, it does not work why? And to get the average, what is the term for diving by the number of value's in the array?
-
I'm not lying. My freind told me he needs to do this, I am not sure if it is his homework or not lol, probebly is