Jump to content

user23

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

user23's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Would having the array on a seperate page to where the subjects are being echoed make a difference? anyone??
  2. pretty sure this is supposed to add the data input to db $register_data = array( 'username' => $_POST['username'], 'password' => $_POST['password'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'school' => $_POST['school'], 'subject_name' => $_POST['subject_name'], 'email_code' => md5($_POST['username'] + microtime()) it was adding to the db fine until i added the dropdown and checkbox part of the code!
  3. ha, sorry! Its not adding the user to the database :/ something is stopping the information from adding to the db
  4. Thanks very much for your help again! Its still not working though and I think its cause most of the user input is on the register page and that part is fine! however from the dropbox on data is being sent to the getuser.php but i dont know how to fix this? :/
  5. Thank you so much for your help guys. Ive made the adjustments you suggested but its still not adding to the db register.php file <?php if (isset($_GET['success']) && empty($_GET['success'])) { //if success is added to end of url echo 'You\'ve been registered successfully!'; } else { if (empty($_POST) === false && empty($errors) === true) { //if post data is not empty and there are no errors we can register user $register_data = array( 'username' => $_POST['username'], 'password' => $_POST['password'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'school' => $_POST['school'], 'subject_name' => $_POST['subject_name'], 'email_code' => md5($_POST['username'] + microtime()) ); register_user($register_data); header('Location: register.php?success'); exit(); }else if (empty($errors) === false){ echo output_errors($errors); } ?> <form method="get" action="http://www.google.com/search"> <input type="text" name="q" size="30" x-webkit-speech /> <input type="submit" value="Google Search" /> </form> <input type='text' onkeyup='ajax();' oninput='ajax();' placeholder='Search for a contact...' x-webkit-speech > <form action="" method="post"> <ul> <li>--------------Personal Details-----------------</li> <li> Username*:<br> <input type="text" name="username"> </li> <li> Password*:<br> <input type="password" name="password"> </li> <li> Password again*:<br> <input type="password" name="password_again"> </li> <li> First Name*:<br> <input type="text" name="first_name"> </li> <li> Last Name:<br> <input type="text" name="last_name"> </li> <li> Email*:<br> <input type="text" name="email"> </li> <li> --------------------Subjects Area ------------------ </li> <html> <head> <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="school" onchange="showUser(this.value)"> <option value="">Select your school:</option> <option value="1">St Marys, Charleville</option> <option value="2">CBS, Charleville</option> </select> </form> <br /> <div id="txtHint"><b>school/subjects will be listed here.</b></div> </body> </html> <li> <input type="submit" value="register"> </li> </ul> </form> <? } include 'includes/overall/overallfooter.php'; ?> getuser.php <?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'root', 'root'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("lr", $con); $sql="SELECT subject_name FROM subjects WHERE id = '".$q."'"; $result = mysql_query($sql); echo "<table border='0' style='background-color: transparent; color: black;'> <tr> <th>Please Select your subjects</th> </tr>"; echo "<br>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "$subject_name"; echo "<td>" . $row['subject_name'] . "</td>"; echo "<td>"; echo "<input type='checkbox' name='$subject_name' value='subject_name'>"; echo "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?>
  6. hey guys ok my issue is a have a register page where you enter data into textboxes and they are in an array which is sent to a db! all that is fine, however, now iv added a dropbox where you select a school, then once a school has been selected the subjects the school offers appears with radio buttons attached to them..my problem is i dont know how to add them to the db.. with the inputboxes it was easier as they were named if (empty($_POST) === false && empty($errors) === true) { //if post data is not empty and there are no errors we can register user $register_data = array( 'username' => $_POST['username'], 'password' => $_POST['password'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'school' => $_POST['school'], 'email_code' => md5($_POST['username'] + microtime()) ); register_user($register_data); header('Location: register.php?success'); exit(); }else if (empty($errors) === false){ echo output_errors($errors); } ?> <form method="get" action="http://www.google.com/search"> <input type="text" name="q" size="30" x-webkit-speech /> <input type="submit" value="Google Search" /> </form> <input type='text' onkeyup='ajax();' oninput='ajax();' placeholder='Search for a contact...' x-webkit-speech > <form action="" method="post"> <ul> <li>--------------Personal Details-----------------</li> <li> Username*:<br> <input type="text" name="username"> </li> <li> Password*:<br> <input type="password" name="password"> </li> <li> Password again*:<br> <input type="password" name="password_again"> </li> <li> First Name*:<br> <input type="text" name="first_name"> </li> <li> Last Name:<br> <input type="text" name="last_name"> </li> <li> Email*:<br> <input type="text" name="email"> </li> <li> School*:<br> <input type="text" name="school"> </li> <li> --------------------Subjects Area ------------------ </li> <html> <head> <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option value="">Select a person:</option> <option value="1">St Marys</option> <option value="2">CBS</option> <option value="3">Presentation, Athenry</option> </select> </form> <br /> <div id="txtHint"><b>Person info will be listed here.</b></div> </body> </html> <li> <input type="submit" value="register"> </li> </ul> </form> <? } include 'includes/overall/overallfooter.php'; ?> However i dont know how you can send dynamic radio buttons??! Also the dropbox uses another php page..which i will add here $con = mysql_connect('localhost', 'root', 'root'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("lr", $con); $sql="SELECT subject_name FROM subjects WHERE id = '".$q."'"; $result = mysql_query($sql); echo "<table border='0' style='background-color: transparent; color: black;'> <tr> <th>Please Select your subjects</th> </tr>"; echo "<br>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "$subject_name"; echo "<td>" . $row['subject_name'] . "</td>"; echo "<td>"; echo "<input type='radio' name='$subject_name'>"; echo "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> 18880_.php
×
×
  • 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.