-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by 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
-
You'll want to use something more like: $result = $ipbwi->DB->query(" SELECT * FROM ibf_arcade_sessions s LIMIT 5 "); $i = 1; while ($r = $ipbwi->DB->fetch_row($result)) { echo '#' . $i . '<br />' . $r['mid'] . '<br />'; } Adam
-
Thin width was just my preference to be honest, I like the look... But I appreciate what you're saying. I'll certainly work on the content changes you said, as I said before the content isn't 100% finished - kind of a first draft that I plan to go through and change the odd bit. Hah yeah I guess they could.. I read somewhere about encoding the email with JavaScript to prevent them scraping it? Probs look into that or removing it. The lightbox I actually coded myself, and just earlier on I over wrote the images used in it by mistake, they were big not so long ago. Thanks for the replies I'll make some changes when I have time! Adam
-
I've posted my portfolio up here before a while ago but I've been doing some work on it and would be interested to know what people think? Content isn't 100% finished but nearly there! Certain features are a bit dicky I'm aware, but mainly design-wise, what's your impressions? The code and CSS' is a little messy at the moment, they will be cleaned up once development is complete though! Also the images may not be the most optimized, but all will be done in due time! http://www.adamswork.net Thanks, Adam
-
Definitely do agree! In comparison to the 'stunning' graphics in the header and footer, the content looks boring! By the way few suggestions to improve it, I'd lighten the footer links up a little and make it smaller.. Also on the contact page (from a PHP developer by trade) I'd expect to see a HTML form, not a mailto link! I'm guessing this site is still early in development as the portfolio and code pages don't work, so well done so far! Keep up the good work! Adam
-
set focus in a textbox at last cursor position
Adam replied to lonewolf217's topic in Javascript Help
Perhaps this will be of use to you.. function setCaretToEnd (input) { setSelectionRange(input, input.value.length, input.value.length); } Taken from: http://www.faqts.com/knowledge_base/view.phtml/aid/13562 There's a few other functions there that look like they may be of use as well! Adam -
Most likely using JavaScript not supported in IE6. Post your code.. Adam
-
Okay fair do's! What are you assigning $fileatt to? Adam
-
The directory the uploaded file is in, or the directory the script is running in? The destination directory must be relative to the directory you're running the script from, not where the file is saved. Adam
-
Try passing "q=test" to every page.. Adam
-
Link doesn't work pal! Adam
-
In my opinion, your opinion is wrong. http://langpop.com/ I don't know how reliable these statistics are, but I'd probably trust Google's results more than the rest. Adam
-
Regular expressions... Adam
-
... Then reading the contents of that page is beyond JavaScript. You'll need to look into using a server-side programming language like PHP; more specifically curl or one of the file functions. Adam
-
You could create a simple function to change the source of the image... function changeImg(obj, url) { if (obj.src) { obj.src = url; } return; } Then call it with onmouseover="changeImg(this, 'rollover3.gif');" .. Adam