Jump to content

natsu

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by natsu

  1. nvm, I got it working
  2. 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; ?>
  3. what do you mean when u say "whatever name your form login field has", would that be the 'emailAddress' and 'password'
  4. 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); ?>
  5. 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>
  6. I solved this. Thanks a lot
  7. I solved this. Thanks a lot
  8. 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 &nbsp"; } ?>
  9. Sorry, but I dont understand what u mean by concentrating the function to the string.
  10. 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
  11. 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); ?>
  12. Yes I understand scope's now but I am trying to do http://www.phpfreaks.com/forums/index.php?topic=348076.msg1642492#msg1642492
  13. 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.
  14. 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?
  15. 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
  16. Of course, btw I am not asking for answer's. I would like answer's like how Pikachu answerd me. That is perfect, I am going to look into that and re-post back here my results.
  17. Not really, but me and my buddy are trying to figure this out and were not able to do it.
  18. I attempted to try to do what was in the comments, but I am not able to do it any help is appreciated <?php $a = array(9, 3, 1, 0, 99, 2, 5, 6, 32, 1, 55); $b = array(9, 18, 1, 0, 23, 22, 4, 6, 5, 32, 55); function getAverage () { echo "The average is " . array_sum($a) . "\n"; // Show the sum of the entire array (should display 19.36) } getAverage(); echo "<br><br>"; function highestValue() { echo $a[max]; // Show the index value of the highest number (should display 4) echo $a(max); // Show the value of index 4 (should display 99) echo $a[min]; // Show the index value of lowest number (should display 3) echo $a(min); // Show the value of index 4 (should display 0) } highestValue(); echo "<br><br>"; function displayMatch() { //Write a function that tests the values of both arrays. If the values at the same index match display the following: "The values at <insert the matching index> match." } displayMatch(); ?>
  19. Using a for loop counting from 0 to 9, I need to make this into a table. Making sure the table is 100% of the page. Any sort of help is appreciated. Thank you 0 1 2 3 4 5 6 7 8 9
  20. Spent about 20-30min on this and I am kinda frustrated why I cant get this to work lol. Some help would be appreciated <?php $max = 10; for ($row = $max; $row >= 0; $row--) { for ($star = 1; $star <= row; $star++) { echo "*"; } } ?> I am trying to get this: ********** ********* ******** ******* ****** ***** **** *** ** *
  21. Thank you. It works now But it displays it backwards (from dec - jan), I tried changing the $i variable number and the case #'s but it still appears backwards.... <?php $i = 11; while($i >= 0) { switch ($i) { case 0: echo "Janurary has 31 days <br>"; break; case 1: echo "Feburary has 28, or 29 days <br>"; break; case 2: echo "March has 30 days <br>"; break; case 3: echo "April has 31 days <br>"; break; case 4: echo "May has 30 days <br>"; break; case 5: echo "June 31 days <br>"; break; case 6: echo "July has 30 days <br>"; break; case 7: echo "August has 31 days <br>"; break; case 8: echo "September has 30 days <br>"; break; case 9: echo "October has 31 days <br>"; break; case 10: echo "November has 30 days <br>"; break; case 11: echo "December has 31 days <br>"; break; } $i--; } ?>
  22. Ok I got this so far... No errors but I am not looping through, I am trying to get all the case's displayed one by one <?php $i = 11; while($i >= 0) { switch ($i) { case 0: echo "Janurary has 31 days"; break; case 1: echo "Feburary has 28, or 29 days"; break; case 2: echo "March has 30 days"; break; case 3: echo "April has 31 days"; break; $i--; } } ?>
  23. Yes I did read the manual Ok here is my attempt that I tried to do for the while/loop <?php $i = 11; while($i => 0) { switch ($i): case 0: echo "Janurary has 31 days"; break; case 1: echo "Feburary has 28, or 29 days"; break; case 2: echo "March has 30 days"; break; case 3: echo "April has 31 days"; break; $i--; } ?>
  24. I did attempt for hours lol.. And I fixed the sort btw, I only need to know how to do the other 2. The For loop and the while/switch
  25. I got 3 problems I am not able to do with the following PHP code 1) The sort function is not sorting the months in order like how I want it? Why? 2) How would I use a for loop to display the array of months? 3) How would I use a while loop and switch statements to display the array of months with # of days in each? <?php $calendar = array("Janurary", "Feburary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); print_r ($calendar); echo "<h1>FOR loop</h1>"; echo "(put for loop code here)"; echo "<br>"; sort($calender); echo "<br>"; print_r ($calendar); echo "<h1>WHILE loop, SWITCH statement</h1>"; echo "(put while loop code here)"; echo "<br>"; ?>
×
×
  • 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.