Jump to content

The_Thorn

Members
  • Posts

    18
  • Joined

  • Last visited

The_Thorn's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you both very much. Problem fixed! I do really appreciate all of your help. Kind regards, Matthew
  2. I have a strange problem which I just cannot figure out. Some background before the question: I hired a programmer to build a feature for my site last year. I fear she tamperd with the code in ways she should not have and now it is not working correctly like it used to. PROBLEM: When a user completes a form and submits it, all fields are saved to my DB/table except for the userName and password fields. I have scoured the code for two days now and cannot figure out why this is happening, or rather, not happening. Thank you in advance for any hint or push in the correct direction regarding this specific issue! Here is the code: (Please see start of issue at line 153) <!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" xml:lang="en" lang="en"> <head> <title>Sliding Login Panel with jQuery 1.3.2</title> <meta name="description" content="Demo of a Sliding Login Panel using jQuery 1.3.2" /> <meta name="keywords" content="jquery, sliding, toggle, slideUp, slideDown, login, login form, register" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <!-- stylesheets --> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <link rel="stylesheet" href="css/slide.css" type="text/css" media="screen" /> <!-- PNG FIX for IE6 --> <!-- http://24ways.org/2007/supersleight-transparent-png-in-ie6 --> <!--[if lte IE 6]> <script type="text/javascript" src="js/pngfix/supersleight-min.js"></script> <![endif]--> <!-- jQuery Slide --> <script src="http://code.jquery.com/jquery-latest.js"></script> <!-- Sliding effect --> <script src="js/slide.js" type="text/javascript"></script> <script> function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } $(document).ready(function() { $('.error_message').hide(); $('#first_val').val(Math.floor(Math.random()*11)); $('#second_val').val(Math.floor(Math.random()*11)); $('#loadingGif').hide(); $('.bt_register').click(function(e){ $('#loadingGif').show(); e.preventDefault(); $('.error_message').hide(); $('#email_error').html("Please enter a valid email."); $('#user_error').html('Required'); error=false; if ($('#user').val().length<1) { error=true; $('#user_error').show(); } if ($('#email').val().length<1 || !validateEmail($('#email').val())) { error=true; $('#email_error').show(); } if ($('#pass').val().length< { error=true; $('#pass_error').show(); } if ($('#city').val().length<1) { error=true; $('#city_error').show(); } if ($('#pass').val() != $('#confirmpass').val()) { error=true; $('#confirmpass_error').show(); } var disallowed_characters=/www|http|@|com|\./; if (disallowed_characters.test($('#city').val())) { error=true; $('#city_error').show(); } if (disallowed_characters.test($('#company').val())) { error=true; $('#company_error').show(); } $.getJSON('ajax.php?username='+$('#user').val(), function(data) { if (data.error) { error=true; alert('An error has occured'); } else { if (!data.isUnique) { error=true; $('#user_error').html('This username is already taken.'); $('#user_error').show(); } } $.getJSON('ajax.php?email='+$('#email').val(), function(data) { if (data.error) { error=true; alert('An error has occured'); } else { if (!data.isUnique) { error=true; $('#email_error').html('This email is already being used.'); $('#email_error').show(); } } if ($('#equals_val').val() != (parseInt($('#first_val').val()) + parseInt($('#second_val').val()))) { error=true; $('#captcha_error').show(); } if (!error) { console.log('submit'); $('#member-signup').submit(); } $('#loadingGif').hide(); }); }); }) }) </script> <!--Favicon--> <link rel="icon" href="favicon.ico" type="image/x-icon"/> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/> <!--Country Dropdown--> <!-- <msdropdown> --> <link rel="stylesheet" type="text/css" href="css/msdropdown/dd.css" /> <script src="js/msdropdown/jquery.dd.min.js"></script> <!-- </msdropdown> --> <link rel="stylesheet" type="text/css" href="css/msdropdown/flags.css" /> <style> .error_message { color: #cf1717; font: Arial; font-size: 14px; display:block; } #panel { height: auto; } </style> </head> <body> <?php define('DB_HOST','localhost'); define('DB_NAME','******'); define('DB_USER','******'); define('DB_PASSWORD','******'); $con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL:" . mysql_error()); $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL:" . mysql_error()); function NewUser() { $userName = $_POST['userName']; $email = $_POST['email']; $password = $_POST['password']; $countries = $_POST['countries']; $city = $_POST['city']; $company = $_POST ['company']; $state = $_POST ['state'];//Added 11/3/2014 $query = "INSERT INTO Table4 (userName,email,password,countries,city,company,state) VALUES ('$userName','$email','$password','$countries', '$city','$company','$state')"; $data = mysql_query ($query)or die(mysql_error()); if($data) { echo $state //echo "YOUR REGISTRATION IS COMPLETED..."; } } function SignUp() { if(!empty($_POST['userName'])) //checking the 'user' name which is from Sign-Up.html, is it empty or have some text { if ($_POST['equals_val'] != ($_POST['first_val'] + $_POST['second_val'])) { echo "CAPTCHA IS NOT CORRECT"; } else { $query = mysql_query("SELECT * FROM WebsiteUsers WHERE userName = '$_POST[user]' AND pass = '$_POST[pass]'") or die(mysql_error()); if(!$row = mysql_fetch_array($query) or die(mysql_error())) { NewUser(); } else { echo "SORRY...YOU ARE ALREADY REGISTERED USER..."; } } } } if(isset($_POST['submit'])) { SignUp(); } if (isset($_POST['type'])) { if ($_POST['type'] == "login") } ?> <!-- Panel --> <div id="toppanel"> <div id="panel"> <div class="content clearfix"> <div class="left"> <h1>Welcome to RedLineDown</h1><div style="color:#FFFFFF;">RedLineDown</div> <p class="grey">###</p> </div> <div class="left"> <!-- Login Form --> <form class="clearfix" action="#" method="post"> <h1>Member Login</h1> <input type="hidden" name="type" value="login" /> <label class="white" for="log">Username:</label> <input class="field" type="text" name="log" id="log" value="" size="23" /> <label class="white" for="pwd">Password:</label> <input class="field" type="password" name="pwd" id="pwd" value="" size="23" /> <div class="clear"></div> <input type="submit" name="submit-form" value="Login" class="bt_login" /> </form> </div> <div class="left right"> <!-- Register Form --> <form method="POST" id="member-signup" action="dbConnect.php"> <h1>Not a member yet? Sign Up!</h1> <input type="hidden" name="type" value="signup" /> <!-- Username Field --> <label type="grey" for="signup">Username:</label> <input type="field" type="text" name="user" id="user" value="" size="23")/><span class='error_message' id='user_error'>Required</span> <!-- Email Field(s) --> <label type="grey" for="email">Email:</label> <input type="field" type="text" name="email" id="email" size="23" /><span class='error_message' id='email_error'>Please enter a valid email.</span> <!-- Password Field --> <label type="grey" for="email">Password:</label> <input type="password" name="pass" id="pass" size="23" /><span class='error_message' id='pass_error'>Password must be at least 8 characters long.</span> <!-- Password Field --> <label type="grey" for="email">Confirm Password:</label> <input type="password" name="confirmpass" id="confirmpass" size="23" /><span class='error_message' id='confirmpass_error'>Passwords do not match.</span> //Insert countries here (Dropdown) <!-- City Field --> <label type="grey" for="email">City:</label> <input type="field" type="text" name="city" id="city" size="23" /> <select name="state" id="state"> <option value="AK">AK</option> <option value="AL">AL</option> <option value="AR">AR</option> <option value="AZ">AZ</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DC">DC</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="IA">IA</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="MA">MA</option> <option value="MD">MD</option> <option value="ME">ME</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MO">MO</option> <option value="MS">MS</option> <option value="MT">MT</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="NE">NE</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NV">NV</option> <option value="NY">NY</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VA">VA</option> <option value="VT">VT</option> <option value="WA">WA</option> <option value="WI">WI</option> <option value="WV">WV</option> <option value="WY">WY</option> </select> <span class='error_message' id='city_error'>Please enter a valid city.</span> <!-- Company Field --> <label class="white" for="email">Company:</label> <input class="field" type="text" name="company" id="company" size="23" /> <span class='error_message' id='company_error'>Please enter a valid company name.</span> <label class="white" for="captcha">Are you human:</label><br> <input class="field" type="text" name="first_val" id="first_val" style="width: 30px;" size="3" disabled/> + <input class="field" type="text" name="second_val" id="second_val" style="width: 30px;" size="3" disabled/> = <input class="field" type="text" name="equals_val" id="equals_val" style="width: 30px;" size="3" /><br> <span class='error_message' id='captcha_error'>Captcha is not correct.</span> <input type="submit" name="submit-form2" value="Register" class="bt_register" /> <img src="loading.gif" id="loadingGif"> <!-- Captcha --> </form> </div> </div> </div> <!-- /login --> <!-- The tab on top --> <div class="tab"> <ul class="login"> <li class="left"> </li> <li>Hello Guest!</li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#">Log In | Register</a> <a id="close" style="display: none;" class="close" href="#">Close Panel</a> </li> <li class="right"> </li> </ul> </div> <!-- / top --> </div> <!--panel --> <div id="container"> <div id="content" style="padding-top:100px;"> </div><!-- / content --> </div><!-- / container --> </body> </html>
  3. Hello. I have been working on and researching this issue for the past day without resolution: When a User selects a country via a dropdown on a form, upon submission it should be added to the table. But it isn't. I've tried everything I can think of. DB connection is fine - All other fields in the form go into the table properly. It's just the country dropdown I'm having problems with. NOTE: This also include HTML $con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error()); $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error()); function NewUser() { $userName = $_POST['user']; $email = $_POST['email']; $password = $_POST['pass']; $countries = $_POST['countries']; $query = "INSERT INTO WebsiteUsers (user,email,pass,countries) VALUES ('$userName','$email','$password', '$countries')"; $data = mysql_query ($query)or die(mysql_error()); if($data) { echo "YOUR REGISTRATION IS COMPLETED..."; } } ... <div id="toppanel"> <div id="panel"> <div class="content clearfix"> <div class="left"> <h1>Welcome to ***********</h1> <p class="grey">You can put anything you want in this sliding panel:</p> </div> <div class="left"> <!-- Login Form --> <form class="clearfix" action="#" method="post"> <h1>Member Login</h1> <label class="grey" for="log">Username:</label> <input class="field" type="text" name="log" id="log" value="" si ze="23" /> <label class="grey" for="pwd">Password:</label> <input class="field" type="password" name="pwd" id="pwd" size="23" /> <div class="clear"></div> <input type="submit" name="submit" value="Login" class="bt_login" /> </form> </div> <div class="left right"> <!-- Register Form --> <form method="POST" action="dbConnect.php"> <h1>Not a member yet? Sign Up!</h1> <!-- Username Field --> <label class="grey" for="signup">Username:</label> <input class="field" type="text" name="user" id="user" value="" size="23" /> <!-- Email Field(s) --> <label class="grey" for="email">Email:</label> <input class="field" type="text" name="email" id="email" size="23" /> <!-- Password Field --> <label class="grey" for="email">Password:</label> <input class="field" type="text" name="pass" id="pass" size="23" /> <Continued> <label class="grey" for="dropdown">Country:</label> <name="pass" id="pass"/> <select name="countries" id="countries" style="width:290px;"> <option value='us' data-image="images/msdropdown/icons/blank.gif" data-imagecss="flag us" data-title="United States" selected="selected">United States</option> <option value='ad' data-image="images/msdropdown/icons/blank.gif" data-imagecss="flag ad" data-title="Andorra">Andorra</option> I'm sorry for the sloppy formatting - It's still rough. (*Full code available upon request) Thank you in advance for any assistance! Matthew *I apologize if this is in the wrong section - Admin/Mods please move if necessary. Thank you.*
  4. Thank you, Sir! I learn so much from this fine site.
  5. This is the current code for revDisp5.php: <?php session_start(); ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); $con = mysql_connect("localhost","admin1000","2Bridlepath2","test1"); if (!$con) { die('NEIN!' . mysql_error()); } //Connect to DB mysql_select_db('test1', $con) or die("Lost"); // does the id exist? if(isset($_GET['id'])) { // get the record id $record_id = intval($_GET['id']) or die("STOPPED!"); echo "<table border='1'> <tr> <th>Employee Name</th> <th>Employee Address</th> </tr>"; // fetch the record that matches the id $result = mysql_query("SELECT * FROM testTable1 WHERE id = $record_id") or die (mysql_error()); $row = mysql_fetch_array($result); //test1 $arraystring = print_r($row, true); $arraystring = '<pre>'.print_r($row, true).'</pre>'; //test2 $comma_separated = implode(",", $row); echo $comma_separated; // echo '<table><tr>'; echo '<td>'; echo '<Strong>Name:</strong><br/>'; echo $comma_separated; echo '</td>'; echo '</tr></table>'; } mysql_close($con); ?> http://redlinedown.com/revDisp5.php?id=105 Thank you, Ch0cu3r
  6. Hi. Ok, did that. Thank you. Please look at and submit: http://redlinedown.com/ob_res5.php The result displays converted arrays (This is the closest I've come to getting anything to display). I do not understand why this is displaying all elements TWICE; I do not need the row ID displayed. Please comment if you get the chance.
  7. Now I am getting the following when redirecting page: Notice: Use of undefined constant test1 - assumed 'test1' in /home/admin1000/public_html/revDisp5.php on line 14 Employee Name Employee Address Name: Notice: Array to string conversion in /home/admin1000/public_html/revDisp5.php on line 39 Array
  8. Form/Redirect Page: <?php session_start(); $_SESSION['test'] = $row; ob_start(); ?> <html> <body> <form method="post" action="<?php $_PHP_SELF ?>"> <table width="400" border="0" cellspacing="1" cellpadding="2"> <tr> <td width="100">Employee Name</td> <td><input name="emp_name" type="text" id="emp_name"></td> </tr> <tr> <td width="100">Employee Address</td> <td><input name="emp_address" type="text" id="emp_address"></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td width="100"> </td> <td> <input name="add" type="submit" id="add" value="Add Employee"> </td> </tr> </table> </form> <?php $con = mysql_connect("localhost","admin1000","2Bridlepath2","test1"); if (!$con) { die('N0! ' . mysql_error()); } //Connect to DB $res = mysql_query("SHOW DATABASES"); while ($row = mysql_fetch_assoc($res)) { echo $row['Database'] . "\n"; } mysql_select_db(test1, $con) or die("Lost"); //Detect DB $sql="INSERT INTO testTable1 (emp_name, emp_address) VALUES ('$_POST[emp_name]','$_POST[emp_address]')"; if (!mysql_query($sql,$con)) { die('Error:' . mysql_error()); } //Add entry to DB ?> <?php $redirect_page = 'http://redlinedown.com/revDisp4.php'; $redirect = true; if ($redirect == true AND !empty($_POST)) { header("Location:$redirect_page"); exit(); } ob_end_flush(); ?> When User submits form (This page, above), the page redirects and displays User input. Thank you.
  9. I have been struggling with this issue for some time; Reading, researching the possible problem(s). Still, I cannot produce the desired result: User enters data into form fields User submits data Page redirects User input needs to be displayed in a table on the resulting page It is number 4. that I'm having trouble with. No matter what I've tried, I cannot get the form data, input, to display on the redirected page. Here is the sloppy, redundant code: <?php session_start(); ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); $con = mysql_connect("localhost","admin****","*Bridlepath*","test*"); if (!$con) { die('NEIN!' . mysql_error()); } //Connect to DB //(Possible offender below) $res = mysql_query("SHOW DATABASES"); while ($row = mysql_fetch_assoc($res)) { echo $row['testTable1'] . "\n"; } mysql_select_db(test1, $con) or die("Lost"); echo "<table border='1'> <tr> <th>Employee Name</th> <th>Employee Address</th> </tr>"; $result = mysql_query("SELECT * FROM testTable1 LIMIT 1") or die (mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['emp_name'] . " " . $row['emp_address']; echo "<br>"; } $result = mysql_query("SELECT * FROM testTable1 LIMIT 1") or die (mysql_error()); while($row = mysql_fetch_array($result)) { echo '<table><tr>'; echo '<td>'; echo '<Strong>Name:</strong><br/>'; echo $row; echo '</td>'; echo '</tr></table>'; } echo '<p>The session value for test is now: ' . $_SESSION[test] . '</p>'; mysql_close($con); ?> Thank you in advance for any advice or help.
  10. Thank you for pointing those errors out. I appreciate it. I fixed that. But, when running it, I now get This webpage has a redirect loop - I'm not even sure what that means, exactly - I am only redirecting once.
  11. I have been researching this, with varying results. This is just a test at this point: User enters data in form > Submits to DB Page refreshes to new, different page I am using the following in my file: header('Location:/ newPage.php '); When I test this, the page IS redirected, but not to the correct page as coded. It loads a default, company-server advertisement page, stating it could not locate the requested URL/file. This file, newPage.php, lives on the server. Any ideas? Is my syntax incorrect? Thank you in advance. The_Thorn
  12. I fixed it! It works great. Now that this relatively simple issue is resolved, I am relieved and can move on in dev. I learned much in the process. I thank all of you here for your help and guidance. The_Thorn
  13. Yes, still having issues. Now cannot connect to the server/DB (?) - The code has not changed regarding credentials. But more importantly, mac_gyver, I just enrolled in an online class for PHP/MySql. I studied "Database Design" in school, but it was highly theoretical, overall. I am starting at the base-level to learn how to do this properly. The project I have planned is large and is worth the investment of my time to become a better programmer. The_Thorn
  14. Thank you, AJinNYC! I shall try this and report back. (By the way - NYC? Great. I am QUITE close by). Again, thank you and all others for your the help. It means a lot! I will get this to work. (Eventually. LOL) The_Thorn
×
×
  • 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.