robbaust
Members-
Posts
20 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
robbaust's Achievements
Newbie (1/5)
0
Reputation
-
Hi please could someone help me I'm trying to learn javascript from a book and some online tuts but have lost myself in it all basically I want to create a user registration page which then saves the users username and password to a cookie then redirects the user to a login page, once on the login page the user enters there username and password then gains access to say a members page. I just can't seem to tie them together and I know this is not secure but this will never go online as like I said I'm just learning javascript These are the codes I have been working with, sorry if these look totally rubbish Thank You very much in advance for any help offered Robert PS: I really want to learn this so please don't tell me to go look at jquery or PHP thank you user_register.html <!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> <script src="cookieFunction.js"></script> </head> <body> <body id="body" onLoad="checkCookie()"> <form name="user_register"> Username: <input type="text" name="user" size="20" value="user"><p> Password: <input type="text" name="pass" size="20"><p> <input type="button" value="login" onClick="setCookie()"> </form> </body> </html> loginForm.html <html> <head> <title>Untitled Document</title> <script src="file:///UNI STUFF/javawebsite/cookieFunction.js"></script> <script type="javascript"> function setCookie() { setCookie("user".document.loginForm.user,value,365); setCookie("pass".document.loginForm.pass,value,365); } </script> </head> <body> <body onload="checkCookie()"> <script type="javascript"> user = getCookie("user"); pass = getCookei("pass"); </script> <form name="loginForm"> Username: <input type="text" name="user" size="20" value="user"><p> Password: <input type="text" name="pass" size="20"><p> <input type="button" value="login" onClick="http://www.google.co.uk"> </form> </p> </body> </html> cookieFunction.js function setCookie(loginForm,value,exdates) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdate); var cookieValue = escape (value) + ((exdate == null) ? "": ";expires= " + exdate.toUTCSring()); document.cookie=cookieName + " = " + cookieValue ; } function getCookie(loginForm) { var i,x,y,cookieTray=document.cookie.split(";"); for (i=0;i<cookieTray.length;i++) { x=cookieTray[i].substr(0,cookieTray[i].indexOF("=")); y=cookieTray[i].substr(cookieTray[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==loginForm) { return unescape(y);} } return(null); }
-
Hi thanks for that info but I forgot to say I'm a newbie so need abit of help with what you said as a friend helped with the code I have saw but he doesn't know how to get it to do the line count thing we kind of cobbled that together Sorry for being dim and a paid Thanks Rob
-
Hi please could someone point me in the right direction I have to do a piece of javascript that asks the user to type in a sentence then print out each word on a separate line then count out a given letter (say the letter A) and display how many times that letter appears in that word the number also needs to appear beside that word so say apple a day keeps the doctor away would print out apple 1 a 1 day 1 keeps 0 the 0 doctor 0 away 2 I hope this makes sense here is my code cheers rob <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Words with an A</title> <script type="text/javascript"> var theText = prompt('Please enter the text that you want to check') function WordsWithA(phrase) { this.phrase = phrase // Assign paramater phrase to the variable phrase var wordsArray = phrase.split(" "); // Split the phrase into indivisual words var aWordCount = 0; // Create variable that will contain the number of words with the letter a in for(var i=0; i<wordsArray.length; i++) // Loop over the words array { document.write(wordsArray[i]+ "<br />") // Output each word to the document and add a line break after each one if(wordsArray[i].indexOf("a") > -1) // Check to see if the word contains a letter a { aWordCount +=1; // If the word contains a letter a, add one to the count } } alert(aWordCount + " of the provided words contain the letter a"); // Output the number of words with an a in an alert dialogue } WordsWithA(theText); </script> </head> <body>
-
Hi there I'm playing around with this code www.rob_austin.co.uk/bbc but getting this error MM_XSLTransform error. Error opening I know it's something to do with the fOpen statement but don't know where to go from here, I have tried to use th cUrl statement but nothing seems to work, so just wondering if anyone can help me this is the code // avoid protocol upper case $mySrc = $protocol . substr($src, $pos); $magic_quotes_runtime_orig = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); if ($myFile = @fopen($mySrc, 'rb')) { while ($data = fread($myFile, 2048)) { $fileContent .= $data; } fclose($myFile); } else { $this->setError($this->getErrorFromCode('MM_OPEN_REMOTE_ERROR', array($src))); if ($protocol == 'https') { $this->setError($this->getErrorFromCode('MM_HTTPS_OPEN_ERROR', array($src))); if ( (substr(PHP_VERSION, 0, 1) < 5) && (substr(PHP_VERSION, 2, 1) < 3) ) { $this->setError($this->getErrorFromCode('MM_HTTPS_NOT_SUPPORTED_ERROR', array($src))); } } } set_magic_quotes_runtime($magic_quotes_runtime_orig); return $fileContent; } function getLocalFile(&$src) { $fileContent = ''; $mySrc = realpath($src); if (!file_exists($mySrc)) { $this->setError($this->getErrorFromCode('MM_OPEN_FILE_ERROR', array($src))); return $fileContent; } clearstatcache(); if (!is_readable($mySrc)) { $this->setError($this->getErrorFromCode('MM_FILE_NOT_READABLE_ERROR', array($src))); return $fileContent; } $magic_quotes_runtime_orig = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); if ($myFile = fopen($mySrc, 'rb')) { while ($data = fread($myFile, 4096)) { $fileContent .= $data; } fclose($myFile); } set_magic_quotes_runtime($magic_quotes_runtime_orig); return $fileContent; } Thanks in Advance for any help you guys can offer Regards Rob
-
thank you once again for all your help seanlim really appreciated all your help these past couple of days Rob
-
hi seanlim yeah that worked great thank you but how would i stop it from showing the results if someone backspaces to the beginning
-
Hi sorry my i ask two final questions please if a person as typed something in the search box then backspaces how would i get my script to stop showing all the results until they start typing in again and do you know when you type something in a box and the popup box thing shows that as something you typed in before how can you stop that I have uploaded a picture to show what i mean thanks for your time again [attachment deleted by admin]
-
thanks seanlim I think i have it working www.spinfish.co.uk/test.html
-
hi seanlim sorry i have kind of lost the plot today as stated in my PM to you how would i get images to show the images are coming from a folder on my server but can't seem to get them to show if you look at my site www.spinfish.co.uk/test.html it just shows the file location or an broken image icon (firefox) description.php <?php if(!isset($_GET['id'])) exit("No ID set"); mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $fishing = mysql_query("SELECT title, description, images FROM fishing WHERE id='".mysql_real_escape_string(intval($_GET['id']))."'"); $images = mysql_query("SELECT images FROM fishing WHERE id='".mysql_real_escape_string(intval($_GET['id']))."'"); if(mysql_num_rows($fishing)==0) exit("Record doesn't exist"); $fish = mysql_fetch_assoc($fishing); echo $fish['title'] . "<BR/>\n"; echo $fish['description'] . "<BR/>\n" . "<BR/>\n"; echo $fish['images']; echo '<img src=/images/'; ?> getfishing.php <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $partialFishing = $_GET['partialfish']; $fishing = mysql_query("SELECT id, title, images FROM fishing WHERE title LIKE '%$partialFishing%'"); while ($fish = mysql_fetch_assoc($fishing)){ echo "<div>"."<a href='description.php?id=".$fish['id']."'>".$fish['title']."</a>"."</div>"; } ?> index.html <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js"></script> <script type="text/javascript"> function getfishing(value) { $.get("getfishing.php",{partialfish:value},function(data){ $("#results").html(data); }); } </script> </head> <body> <input name="search" onKeyUp="getfishing(this.value)" id="search" size="35" /> <input type="submit" name="submit" id="submit" value="Submit" /> </form> <br> <div id="results"></div> </body> </html> and this is my database [attachment deleted by admin]
-
WORKING Thank you so much Seanlim I really really appreciate what you have done Thank You Robert
-
i have uploaded the files to my website www.spinfish.co.uk/test.html
-
Seanlim these are the files i have getfishing.php <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $partialFishing = $_GET['partialfish']; $fishing = mysql_query("SELECT id, title FROM fishing WHERE title LIKE '%$partialFishing%'"); while ($fish = mysql_fetch_assoc($fishing)){ // add this next line var_dump($fish); echo "<div>"."<a href='description.php?id=".$fish['id']."'>".$fish['title']."</a>"."</div>"; } ?> the description.php you gave me and the index.html <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js"></script> <script type="text/javascript"> function getfishing(value) { $.get("getfishing.php",{partialfish:value},function(data){ $("#results").html(data); }); } </script> </head> <body> <input name="search" onKeyUp="getfishing(this.value)" id="search" size="35" /> <input type="submit" name="submit" id="submit" value="Submit" /> </form> <br> <div id="results"></div> </body> </html>
-
sorry yes i copied the code as you pointed out this is all i'm getting array(2) { ["id"]=> string(1) "1" ["title"]=> string(50) "SALMON River Dee, Ballogie Estates, Aberdeenshire " } <div><a href='description.php?id=1'>SALMON River Dee, Ballogie Estates, Aberdeenshire </a></div> really sorry for putting on you like this
-
this is what the sorce code is saying array(1) { ["title"]=> string(50) "SALMON River Dee, Ballogie Estates, Aberdeenshire " } <div><a href='description.php?id='>SALMON River Dee, Ballogie Estates, Aberdeenshire </a></div> and yes every record as an id
-
http://localhost/description.php?id=