-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
...eh? That's pretty different code to your first post. Which query exactly are you trying to cycle through? Adam
-
Add: $email_webuser = mysql_real_escape_string($_POST['email_webuser']); ... somewhere before the query in your file. Adam
-
There's no existing function in JavaScript to validate an email (at least to my knowledge) so you'd probably need to use a custom function (there's loads on Google - I'll just use the one from first result) .. <script LANGUAGE="JavaScript"> <!-- function validate(frm) { // // Check the Email field to see if any characters were entered // if (frm.productuse.value.length == 0) { alert("Please tell us why you require this product."); frm.productuse.focus(); return false; } else if (frm.disclaimer.checked == false) { alert("You must read the disclaimer before requesting a quote."); frm.disclaimer.focus(); return false; } else if (is_email(frm.custemail.value) == false) { alert("Please enter a valid email address."); frm.custemail.focus(); return false; } } function is_email(str) { var at="@"; var dot="."; var lat=str.indexOf(at); var lstr=str.length; var ldot=str.indexOf(dot); if (str.indexOf(at)==-1){ return false; } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false; } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false; } if (str.indexOf(at,(lat+1))!=-1){ return false; } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false; } if (str.indexOf(dot,(lat+2))==-1){ return false; } if (str.indexOf(" ")!=-1){ return false; } return true; } //--> </SCRIPT> Not tested but should work no probs! Adam
-
Where does "$email_webuser" come from? Try using: $r = mysql_query($query) or die(mysql_error()); Adam
-
$src = '../../img/icons/'.$id.'/grav/slides/' .$a; Where does $id come from? Adam
-
Hah oh right - never mind! Adam
-
Try using a different loop.. foreach ($_FILES as $file) { You'd then access the array slightly different.. $filename = $file['userfile']['name']; I've not tested this.. Adam
-
The MySQL behind it.. $rowToGet = 5; // bare in mind results will start at 0 so 5 will return result 6 $query = mysql_query("SELECT * FROM Email_Inb LIMIT ".$rowToGet.", 1"); Hope this helps.. Adam
-
Would it not be possible to have more specific RSS feeds? I don't often go in half the boards here and would be helpful to be able to subscribe to just the boards I want. There's a mod available: http://custom.simplemachines.org/mods/index.php?mod=376 Adam
-
Could you paste the code of your login form (in [ code ] tags)? Be able to then see how your system identifies a logged in user then.. Adam
-
I like the header image, though there's no actual logo or title... Color scheme is dark but works well. I'm not keen on the red inputs on the login & register pages - I think you have the gradient the wrong way round; makes them appear outwards rather than inwards.. if you get me? And I'd make them a little more subtle. With the gap you have on the front page I'd probs put a login form, so you don't have to go to login page every time! I think overall it's got the makings of a nice site but at the minute looks very 'templatish'! Try to fill the main content area better rather than having a smaller table in it! Oh and also you're HTML doesn't validate! Adam
-
[SOLVED] Spacing Problem in table when using Paging...
Adam replied to asad_black's topic in PHP Coding Help
I can't see any difference? Adam -
Looks like crypt to me! Very similar output.. Adam
-
Cant manipulate my last database column within php!...pliiiiiz help
Adam replied to joaca's topic in PHP Coding Help
So what does happen if $row["regno"] doesn't equal $row["firstchoice"], and $row["regno"] doesn't equal $row["secondchoice"], and $row["regno"] doesn't equal $row["thirdchoice"] ? Syntactically, if the conditions said above are met there's no reason why the last 'if' statement wouldn't be run. The problem must lye within your own logic - or data. Try adding some debug like (just after: $rowThree = mysql_fetch_array($resultThree);): print $row['regno'] . '<br />'; print_r($rowThree); To see what values are being passed through the 'if' statements.. Adam -
Flag/Tag and store results in Session or cookie
Adam replied to mikemessiah's topic in Javascript Help
AJAX is the answer! Decent tutorial: http://www.w3schools.com/Ajax/Default.Asp Use AJAX to make a HTTP request to your PHP page whenever they tag the 'result'.. Adam -
Bit difficult seen as you have so many tags in there. You could strip the tags out using "strip_tags()", but you're going to be left with that giant URL at the start. Will every output have one, or is it just this one? "preg_replace()" is an option to filter out any bits you don't want! Adam
-
You wouldn't need to store their password twice. What you're best off doing is checking they are logged in before the message can be submitted. You should have some form of session variable set at login point which allows you to validate / check that they are in fact.. logged in. PHP have built in sessions which you could use to do this if you don't already have anything in place. Best off reading a tutorial on them so you understand exactly what they are first.. http://www.tizag.com/phpT/phpsessions.php Adam
-
Cant manipulate my last database column within php!...pliiiiiz help
Adam replied to joaca's topic in PHP Coding Help
Are the first two intentionally ifs and the second two else ifs? Adam -
help with forms! need to add up lots of values from a drop down menu
Adam replied to krs10_s's topic in PHP Coding Help
Give the drop downs you wish to add up a prefix to the name then loop through the $_POST array and look for that prefix... So you'd have your menus / inputs: <select name="countNumber1">...</select> <select name="countNumber2">...</select> And then loop through them like so: $total = 0; foreach ($_POST as $key => $x) { if (substr($key, 0, 5) == 'count') { $total += (int) $x; } } echo $total; You don't have to use 'count' obviously.. Adam -
It could be that there are no results returned and so $set3 isn't an array. Try adding: $set3 = array(); Just before: foreach ($set1 as $x) { foreach ($set2 as $y) { $query_d = "SELECT distance FROM graph_path WHERE term1_id = '".$set1[$x]."' AND term2_id = '".$set2[$y]."'"; $result_d = mysql_query($query_d) or die(mysql_error()); while ($row_d = mysql_fetch_array($result_d)) { $set3[] = $row_d['distance']; } } } Adam
-
At the moment you're only saving the first result into an array. Try.. while ($row = mysql_fetch_array($result1)) { $set1[] = $row['term_id']; } And.. while ($row = mysql_fetch_array($result2)) { $set2[] = $row['term_id']; } Then to loop through them in the way you said... foreach ($set1 as $x) { foreach ($set2 as $y) { $query_d = "SELECT distance FROM graph_path WHERE term1_id = '".$set1[$x]."' AND term2_id = '".$set2[$y]."'"; $result_d = mysql_query($query_d) or die(mysql_error()); while ($row_d = mysql_fetch_array($result_d)) { $set3[] = $row_d['distance']; } } } That will store all the returned results from the query in a new array called '$set3', which you could loop through like: foreach ($set3 as $val) { print $val . '<br />'; } Hope this helps! I've not tested the code by the way! Adam
-
If you set an ID for the select element you can use: onchange="document.getElementById('elements_id').value=this.text;" If the form has a name: onchange="documents.forms['form_name'].value=this.text;" Or if you work out the form number: onchange="document.forms[0].products_price.value=this.text;" Remember though the form number starts from 0 and not 1! Adam
-
It's not bad, I like the header! But the main content is a little plain, and I can't read the footer text unless I zoom in. For a website like that with some back-end CM, I reckon you could get about £200 (at least round here in Sheffield, UK)... Adam
-
Give this a whirl.. <?php require("include/database.php"); //Database information is stored here, don't forget to use the $db -> command. //Sets all the automatic information. (User info like cookies ect, will be stored in config.php. /*Login processer, checks if the fields are empty, and if the password and username are correct then logs the user in setting the cookies in the process in the config.php file.*/ if (isset($_POST['submit'])) { $username = mysql_real_escape_string($_POST['username']); $password = md5($_POST['password']); $query = mysql_query(" SELECT * FROM users WHERE username = '".$username."' AND password = '".$password."' ") or die('Error: ' . mysql_error()); if (empty($username)) { $error = 1; $error2 .= "<li>Please enter your username.</li>"; } if (empty($password)) { $error = 1; $error2 .= "<li>Please enter your password.</li>"; } if (mysql_num_rows($query) != 1) { $error = 1; $error2 .= "<li>Please enter the correct username or password.</li>"; } if (!$error) { //Set cookies. setcookie('username', '$username', time()+60*60*24*30); setcookie('password', '$password', time()+60*60*24*30); header("Location: logged_in.php"); } } require("config.php"); echo "<head><title>Login</title></head>"; echo "$openHTML"; if ($_POST['submit'] && $error == 1) { echo "<ul>$error2</ul>"; } //Login Form. (Allows for user data input.) ?> Please enter your user details here. <form action="$PHP_SELF" method="post"> Username: <input type="text" name="username"> <br> Password: <input type="password" name="password"> <br> <input type="submit" name="submit" value="Login"> </form> <?php //Closes all the layout data. echo "$closeHTML"; ?> That will redirect on success, display errors and form on fail .. else just the form. (Note that it's far easier to read when the code is indented..) Adam
-
Okay the cookies are failing because you have to set them with the headers, ie. before any HTML is printed out. Don't quite know why you need two queries? Could remove $query1 and just use $query2 to determine if they were logged in successfully - probs considered bad security to tell them if they entered the wrong username anyway! Add "or die('Error: ' . mysql_error());" to the end of your query to give you mire insight as to why it's not working. Like: $query2 = mysql_query ( "SELECT * FROM users WHERE username ='".$_POST['username']."' && password!='".$_POST['password']."'" ) or die('Error: ' . mysql_error()); Then tell us the errors you get.. Adam