Jump to content

BrianM

Members
  • Posts

    217
  • Joined

  • Last visited

    Never

Everything posted by BrianM

  1. Now I get this: You have failed to complete all required fields. is already a registered email address. Notice: Undefined index: gender in C:\Program Files\Apache Group\Apache2\htdocs\community\register.php on line 35 Registration complete! AND, it still inserts the data into the db ... hmm, not sure what to make of this. edit: and I changed the }| after the first empty($_POST to || still didn't work
  2. Before I start dismantling my code, just insert the extra else statement you put in?
  3. The form here is suppose to submit only when all fields are filled in, otherwise it should return an error. Well it does return an error if the fields aren't completely filled in but it still inserts the information into the database, which it's not suppose to do :| Can anyone look this over or skim through and see if they see anything wrong that's causing this problem. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Game Zero - Community</title> <link rel="stylesheet" type="text/css" href="../css/gamezero.css" /> </head> <?php /* MySQL database connection */ mysql_connect('localhost', 'brian', '*password*') or die(mysql_error()); mysql_select_db('gamezero') or die(mysql_error()); if (isset($_POST['register'])) { /* If any field is left blank, return an error */ if (!$_POST['firstName'] | !$_POST['lastName'] | !$_POST['email'] |!$_POST['password'] | !$_POST['gender']) { echo 'You have failed to complete all required fields.'; } /* Is the email already registered in the database? */ $email_check = $_POST['email']; $check_one = mysql_query("SELECT email FROM gamezero_members WHERE email = '$email_check'") or die(mysql_error()); $check_two = mysql_num_rows($check_one); if ($check_two != 0) { echo ''.$_POST['email'].' is already a registered email address.'; } /* Do the passwords match? If not, return an error */ if ($_POST['password'] != $_POST['password_two']) { echo 'Your passwords did not match.'; } /* Store the password using md5 */ $_POST['password'] = md5($_POST['password']); /* Insert values into the database adding the new member */ $insert = "INSERT INTO gamezero_members (firstName, lastName, email, password, gender) VALUES ('".$_POST['firstName']."', '".$_POST['lastName']."', '".$_POST['email']."', '".$_POST['password']."', '".$_POST['gender']."')"; $add_member = mysql_query($insert); ?> Registration complete! <?php /* Show form if `if (isset($_POST['register']))` has not been sent */ } else { ?> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table> <tr><td>First Name:</td><td> <input type="text" name="firstName" maxlength="60" /> </td></tr> <tr><td>Last Name:</td><td> <input type="text" name="lastName" maxlength="60" /> </td></tr> <tr><td>Email:</td><td> <input type="text" name="email" maxlength="60" /> </td></tr> <tr><td>Password:</td><td> <input type="password" name="password" maxlength="60" /> </td></tr> <tr><td>Password Confirm:</td><td> <input type="password" name="password_two" maxlength="60" /> </td></tr> <tr><td>Gender:</td><td> <input type="radio" name="gender" value="Male" /> Male <input type="radio" name="gender" value="Female" /> Female </td></tr> <tr><th> <input type="submit" name="register" value="Register" /> </th></tr> </table> </form> </body> </html> <?php /* End of script */ } ?> Thank you for any help!
  4. Hah, scratch that! I just forgot to type the @domain on the end when I submit my entry :| No wonder I wasn't getting a reply.
  5. Everything worked out great, surprisingly, since this is my first time writing my own PHP registration form that inserts information into a database... until I took a closer look at the `email` field in the database. The problem is, it wont display the entire email which is typed in the form. Say I type my email (medley.brian@yahoo.com), it will only insert 'medley.brian' into the `email` field, leaving off @yahoo.com ... is there anything I should add to my code to have the email insert properly into the database? Here is what I have. Registration page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Game Zero - Community</title> </head> <?php mysql_connect('localhost', 'brian', '*password*') or die(mysql_error()); mysql_select_db('gamezero') or die(mysql_error()); if (isset($_POST['register'])) { if (!$_POST['firstName'] | !$_POST['lastName'] | !$_POST['email'] |!$_POST['password'] | !$_POST['gender']) { echo 'You have failed to complete all required fields.'; } $email_check = $_POST['email']; $check_one = mysql_query("SELECT email FROM gamezero_members WHERE email = '$email_check'") or die(mysql_error()); $check_two = mysql_num_rows($check_one); if ($check_two != 0) { echo ''.$_POST['email'].' is already a registered email address.'; } if ($_POST['password'] != $_POST['password_two']) { echo 'Your passwords did not match.'; } $_POST['password'] = md5($_POST['password']); $insert = "INSERT INTO gamezero_members (firstName, lastName, email, password, gender) VALUES ('".$_POST['firstName']."', '".$_POST['lastName']."', '".$_POST['email']."', '".$_POST['password']."', '".$_POST['gender']."')"; $add_member = mysql_query($insert); ?> Registration complete! <?php } else { ?> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table> <tr><td>First Name:</td><td> <input type="text" name="firstName" maxlength="60" /> </td></tr> <tr><td>Last Name:</td><td> <input type="text" name="lastName" maxlength="60" /> </td></tr> <tr><td>Email:</td><td> <input type="text" name="email" maxlength="60" /> </td></tr> <tr><td>Password:</td><td> <input type="password" name="password" maxlength="60" /> </td></tr> <tr><td>Password Confirm:</td><td> <input type="password" name="password_two" maxlength="60" /> </td></tr> <tr><td>Gender:</td><td> <input type="radio" name="gender" value="Male" /> Male <input type="radio" name="gender" value="Female" /> Female </td></tr> <tr><th> <input type="submit" name="register" value="Register" /> </th></tr> </table> </form> </body> </html> <?php } ?> Database structure: CREATE TABLE `gamezero_members` ( `ID` tinyint NOT NULL auto_increment, `firstName` varchar(60) NOT NULL, `lastName` varchar(60) NOT NULL, `email` varchar(60) NOT NULL, `password` varchar(60) NOT NULL, `gender` varchar(6) NOT NULL, PRIMARY KEY (`ID`) );
  6. CREATE DATABASE `gamezero` CREATE TABLE `members` ( ID TINYINT NOT NULL AUTO_INCREMENT, firstName VARCHAR(60) NOT NULL, lastName VARCHAR(60) NOT NULL, email VARCHAR(60) NOT NULL, password VARCHAR(60) NOT NULL, gender VARCHAR(4) NOT NULL, PRIMARY KEY (ID) ); Here is the error I receive: #1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE `members` ( ID TINYINT NOT NULL AUTO_INCREMENT,
  7. Never mind, I see there was an '(' left out, but I still wont update in the database :| Boy this is fun. I don't know why it wont update... Any suggestions??
  8. For development purposes. And I get: Parse error: parse error in C:\Program Files\Apache Group\Apache2\htdocs\examples\update.php on line 11 on line 11, which is: $sql = "UPDATE example SET 'Required' = '$value' WHERE ID = '1'");
  9. Oh, and if anyone would like me to write the database structure out so they can try this out, I will gladly write an .sql file for you, as I did not take the time to do so just yet, but will upon request, if needed.
  10. To start things off I'll post the source I have at this point. page displaying table and it's content <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <?php mysql_connect("localhost", "brian", ""); mysql_select_db("example"); function returnheaders() { $sql = mysql_query("SELECT * FROM example WHERE ID=1") or die(mysql_error()); $array = mysql_fetch_array($sql); //print_r($array); foreach($array as $key => $value) { if(!is_numeric($key) && $key != "ID") { echo("<td id=\"header_$key\">$key</td>\n"); } } } function returndata() { $sql = mysql_query("SELECT * FROM example"); while($row = mysql_fetch_array($sql)) { echo("<tr id=\"dataset_row".$row['ID']."\">\n"); foreach($row as $key => $value) { if(!is_numeric($key) && $key != "ID") { echo("<td id=\"".$key.$row['ID']."\" nowrap><a id=\"".$key."_".$row['ID']."_value\" href=\"javascript:edit_row(".$row['ID'].");\">".$value."</a></td>\n"); } } echo("</tr>\n"); } } function loaddynamicjava() { echo("<script type=\"text/javascript\">\nvar readylight = true;\nfunction edit_row(row) {\nvar currentval;\n"); $sql = mysql_query("SELECT * FROM example WHERE ID=1") or die(mysql_error()); $array = mysql_fetch_array($sql); foreach($array as $key => $value) { if(!is_numeric($key) && $key != "ID") { echo("currentval = document.getElementById(\"".$key."_\"+row+\"_value\").innerHTML;\n"); echo("document.getElementById(\"".$key."\"+row).innerHTML = "); if($key == "PermitProcess") echo("'<input type=\"button\" name=\"save\" value=\"Save\" onClick=\"savedata('+row+');\">"); else echo("'"); echo("<input type=\"text\" id=\"".$key."_'+row+'\" name=\"".$key."_'+row+'\" value=\"'+currentval+'\" />';\n"); } } echo("}\nfunction savedata(row) {\nif(!ready) { alert(\"System is still saving other data\"); return; }\nready = false;\nvar currentdata;"); foreach($array as $key => $value) if(!is_numeric($key)) if($key == "ID") echo("document.getElementById(\"ID\").value = row;\n"); else echo("document.getElementById(\"".$key."\").value = document.getElementById(\"".$key."_\"+row).value;\n"); echo("document.getElementById(\"theform\").submit();\n"); foreach($array as $key => $value) if(!is_numeric($key) && $key != "ID") { echo("currentdata = document.getElementById(\"".$key."_\"+row).value;\n"); echo("document.getElementById(\"".$key."\"+row).innerHTML = '<a href=\"javascript:edit_row('+row+');\" id=\"".$key."_'+row+'_value\">'+currentdata+'</a>';\n"); } //echo("}"); echo("}\nfunction nowready() { ready = true; }</script>"); } function returnformfields() { $sql = mysql_query("SELECT * FROM example LIMIT 1"); $array = mysql_fetch_array($sql); foreach($array as $key => $value) if(!is_numeric($key)) echo("<input type=\"hidden\" name=\"".$key."\" id=\"".$key."\">\n"); } ?> <?php loaddynamicjava(); ?> </head> <body> <table border="1" cellpadding="0" cellspacing="0"> <tr class="header"><?php returnheaders(); ?></tr> <?php returndata(); ?> </table> <form action="update.php" method="post" target="hiddenframe" name="theform" id="theform"> <?php returnformfields(); ?> </form> <iframe src="about:blank" style="display: none;" name="hiddenframe" id="hiddenframe" onLoad="nowready();">This Page Requires iFrames Which Your Browser Does not support</iframe> </body> </html> update page the form sends to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <?php if (isset($_POST['save'])) { mysql_query("UPDATE `example` SET `Required` = '$value', `Required` = '$value' WHERE `ID` = '1'"); } ?> <body> </body> </html> I'm not sure what kind of mess I've got myself into here, but is what I'm trying to do is figure out whether or not is if(isset($_POST['save'])) is needing to be set to something else, maybe the field name being updated in the table?? ??? It updates in the current table but if I refresh or leave the page it's back to it's original state, and also, it wont save content to the database, which is the main issue I'm having here, not being able to figure out how to write my update.php file. I hope somebody can hint me on what to fix. -Brian
  11. Can somebody show me or point me to an example showing how to making a text field and submit button come up after clicking a link, please?
  12. Well I'm trying to work with the script you provided, but I'm having a bit of trouble figuring out how it makes a connection to the database to update the cell content after using the ajax_inplaceeditor. Any advice? :|
  13. I don't see how this will update content being listed from a database. What I was wondering was how would I go about clicking the cell content a having an input box and submit button pop up under the table for that column and row and click the submit button and whatever was put into the input box replaces the content in the cell, kind of like an error that pops up on the screen when you submit wrong/invalid information or forget to complete a field when filling out a form a notice pops up saying you forgot to do this or that, how would I do that but instead of text, have a submit form for that cell to update the contents.
  14. You've hardly given any information at all, it's quite hard to understand what you want done and what you're trying to accomplish.
  15. Well, back to the help board for me with yet another question. I'm still working on the same website for my fathers engineering company. Each project page for the client had a table on it listing all the information from the project table in the database pertaining to that certain project; permit status, a date certain things are submitted to know if this or that was complete, county meeting dates, etc.) so here's a little about what I'm trying to do. I want each cell on the table to be a link, which I already know how to do this, but here's the part I'm unsure of. I want to be able to click the cell and after clicking it an input box with a submit button pops up right under the table for the cell clicked so that it updates the cell contents with whatever you insert and submit, that is the part I'm unsure of. I was thinking to get the submittal text box to pop up under the table for whatever cell you click I may have to use some sort of a javascript onClick event that I read about on w3schools, although I'm not quite sure, maybe somebody could fill me in on how this might be done. I hope I've shared enough information for somebody to give me some feedback as to how this could be done. Thanks for any help!
  16. i don't even know what i was talking about, heh, just being stupid lol
  17. What sort of problem are you having with it?
  18. Something like this can easily be googled!!! Some people don't even take the time to look. >.> <?php echo sqrt(9); // 3 echo sqrt(10); // 3.16227766 ?> But there is an example.
  19. Anyone know how to make a human being using PHP and maybe some javascript? And maybe an SQL database to hold information obtained through daily living.
  20. Alas! She's working. A huge thank you to all of you who contributed towards my success!!!
  21. HOLY JESUS!!! Praise the Guru gods, >.> heh I never even saw that lol I'm sure that'll fix my problem lol, let me try.
  22. Now it's telling me no database selected >.> I clearly see I have one selected `08-12345-1` .. what's wrong with it now? :[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Examples </title> </head> <?php if(!isset($_POST['text'])) { echo "<form action='/examples/index.php' method='post'>"; echo "<input type='text' name='text'>"; echo "<input type='submit'>"; echo "</form>"; } else { $mysql_connect = mysql_connect('localhost', 'brian', '') or die("Failed to connect"); $text = mysql_escape_string($_POST['text']); mysql_query("UPDATE `08-12345-1` SET Req='$text' WHERE PermitProcess='COUNTY PRE-APP MEETING'") or die("Update error: ".mysql_error()); mysql_close($mysql_connect); echo "The record was updated in your MySQL database!"; } ?> <body> </body> </html>
  23. AHHHH!!!! Still doesn't work. I'm about to pull my hair out Arg. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Examples </title> </head> <?php if(!isset($_POST['text'])) { echo "<form action='/examples/index.php' method='post'>"; echo "<input type='text' name='text'>"; echo "<input type='submit'>"; echo "</form>"; } else { $text = mysql_escape_string($_POST['text']); $mysql_connect = mysql_connect('localhost', 'brian', ''); mysql_query("UPDATE `08-12345-1` SET Req='$text' WHERE PermitProcess='COUNTY PRE-APP MEETING'"); mysql_close($mysql_connect); echo "The record was updated in your MySQL database!"; } ?> <body> </body> </html> This is what I have now, after changing what you stated. I just don't understand why it works in the query window in phpMyAdmin but not when put into this script... >.>
×
×
  • 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.