Everything posted by scaz182
-
Javascript validation
Ok cool I'll look into that thanks!
-
Web folder structure?
Hi people, I was just interested how people structured their website folders? I usually have the following folders /CSS (containing style sheets) /Images (containing Images) /Includes (containing the header and footer which is usually linked to using SSI or PHP). I than have all the pages in the _root. I always figured their must be a better way of setting this out (having all the pages in the same folder can get messy as it grows) I have tried other ways such as splitting up the pages into other folders/categories but I found it to be a pain having to change the links to images, css, includes etc. on different located pages. Does anyone have a method they would like to share?
- zIndex?
-
Javascript validation
Hi, I am looking for a simple javascript validation script that will work on both IE and Firefox. All I really need to do is check if certain fields are empty (I'm not to fussed about correct email etc.) And I guess use an alertbox to inform the user My form looks like this: <form action="contact.php" method="post"> <p><label>*Name:</label> <input type="text" name="name" size="20" maxlength="40" /></p> <p><label>*Email:</label> <input type="text" name="email" size="20" maxlength="40" /></p> <p><label>Subject:</label> <input type="text" name="sub" size="20" maxlength="40" /></p> <p><label>*Message:</label><br/> <textarea cols="25" rows="10" name="body"></textarea></p> <p class="submit"> <input type="submit" name="submit" value="Send"/></p> <p><input type="hidden" name="submitted" value="TRUE"/></p> </form> It's ultimately only the name, email and message boxes that need to be validated. Any help would be much appreciated!
-
Floating form elements
Ahh great, thanks for the quick fix bluedreamer!
-
Floating form elements
Hi people, I have a simple contact form & I want the first three input boxes on the left side and then the main message box and the submit button on the right. I've managed to do this using div tags and floats around the first three boxes and then again around the message box and submit button (although the submit button doesn't move with the message box for some reason) Anyway the problem that occurs form using this method is it stops users from accessing the input boxes on the left. Here's a link to show you what I mean. Does anybody know of a way to achieve this form layout correctly? p.s I'm using a strict doctype. Cheers Rich.
-
to frame on not to frame...is there another option?
You just need to create a div 'container' which contains all other code and apply the following: div#container { position:relative; margin-left:auto; margin-right:auto; width:(your width); } to centre a site and then put a banner/logo/navigation in a div, call it 'header' and add the following to that: div#banner { height:(your height); width:(your width); position:fixed; } my site uses this - link
-
PHP connecting to MySQL problem?
OK I've sorted it! All I did was change the require_once() function's argument to a relative URL instead of an absolute (pretty strange that it matters but I don't care it's done Thanks for all your help people!
-
PHP connecting to MySQL problem?
mmm that is so strange! Thanks very much for testing it AJReading. I am definitely using the ip address as the host and it works fine if I include a simple query within the start.php as you did AJ. I have also double checked my INSERT query works and it does as I've tested it putting it in the connection file as above. This now has me believe there is an issue with the use of the require_once function? Any thoughts? It's driving me crazy!
-
PHP connecting to MySQL problem?
Ok, Streamline have said that they are unaware of any problems with the server! they gave me a test script which works, so I guess there right! this is streamlines test script: <?php $dblink = mysql_connect("serverURL", "USERNAME", "PASSWORD") or die("Could not connect to MySQL server"); $db = mysql_select_db("DATABASENAME") or die("Could not connect to Database"); $res = mysql_query("SHOW TABLES ") or die("Could not run query"); $row = mysql_fetch_array($res); if($row == "") { echo "No tables found, connection works.";} else { echo "Tables found and connections work.<br />Tables found:<br />"; foreach($row as $key => $value){ if(is_numeric($key)){ echo $value."<br />"; } } }?><br />Script created at: 01/05/2008 02:11:32<br />Current time/date: <? echo date("d\/m\/Y h:i:s"); ?> You can see it working here test script This tells me it is actually something in my code! Can anybody spot what is wrong? It's driving me crazy! I'll give you my code again as it's now more complete: <html> <head> <title>Add Book</title> </head> <body> <?php if (isset($_POST['submit'])) { $errors = array(); // validate isbn if (empty($_POST['isbn'])) { $errors[] = 'You did not enter the books ISBN.'; } else { $isbn = trim($_POST['isbn']); } // validate name if (empty($_POST['bname'])) { $errors[] = 'you did not enter the books name.'; } else { $bn = trim($_POST['bname']); } // validate Author if (empty($_POST['author'])) { $errors[] = 'You did not enter the author of the book.'; } else { $a = trim($_POST['author']); } // validate publisher if (empty($_POST['pub'])) { $errors[] = 'You did not enter the books publisher.'; } else { $p = trim($_POST['pub']); } // create short hand for in stock $is = $_POST['stock']; //check errors if (empty($errors)) { require_once ('http://www.richardscarrott.co.uk/PRIVATE/start.php'); $query = "INSERT INTO books (ISBN, Name, Author, Publisher, Stock) VALUES ('$isbn', '$bn', '$a', '$p', '$is')"; $result = @mysql_query ($query); if($result) { echo "<h2>$bn has been added to the database</h2>"; exit(); } else { echo "<h2>You have a system error my friend</h2>"; echo '<p>' . mysql_error() . '<br/><br/>Query: ' . $query . '</p>'; exit(); } } else { echo '<h2>An error has occured with your input</h2> <p>The following errors occurred:<br/>'; foreach ($errors as $msg) { echo " - $msg<br/>\n"; } } } else { ?> <h2>Insert Book into database</h2> <form action="addbook.php" method="post"> <p>ISNB: <input type="text" name="isbn" size="20" maxlength="20" value="<?php if (isset($_POST['isbn'])) echo $_POST['isbn'];?>" /></p> <p>Book Name: <input type="text" name="bname" size="20" maxlength="20" value="<?php if (isset($_POST['bname'])) echo $_POST['bname'];?>" /></p> <p>Author: <input type="text" name="author" size="20" maxlength="20" value="<?php if (isset($_POST['author'])) echo $_POST['author'];?>" /></p> <p>Publisher: <input type="text" name="pub" size="20" maxlength="20" value="<?php if (isset($_POST['pub'])) echo $_POST['pub'];?>" /></p> <p>In Stock: <input type="checkbox" name="stock" value="TRUE" <?php if (($_POST['stock']) == 'TRUE') echo 'checked="checked"';?> /></p> <p> <input type="submit" name="submit" value="Enter" /></p> <!--<input type="hidden" name="submitted" value="TRUE" />--> </form> <?php } ?> </body> </html> and again here is my connection data (which I still believe to be working!): <?php //database access information // define constants DEFINE ('DB_USER', 'username'); DEFINE ('DB_PASSWORD', 'password'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'databasename'); //make connection $dbc = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) OR die('Could not connect to database: ' . mysql_error()); mysql_select_db(DB_NAME) OR die('could not select database: ' .mysql_error()); ?> just in case you haven't read the first post the error message I get is: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Again, any help would be so appreciated! Rich.
-
PHP connecting to MySQL problem?
I'm hosted by streamline.net, I've opened a support ticket with them but as anybody who has used streamline before will know it's rather doubtful that I will get anything useful from them. It would be pretty helpful if you could test to see if you can connect AJReading, just so I don't waste any more time trying to sort out something that isn't my code! I'll PM you the details. I am not connecting through localhost but an ip address streamline has provided for the database server (i don't know if this makes any difference). What is this script you speak of Jem? how would it enter a new record without using mySQL? Cheers.
-
PHP connecting to MySQL problem?
Hi, I am trying to create a program that will insert a new record with the values taken form a form. I think everythin is going fine untill I enter the values and get the error message: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) here is my code: <html> <head> <title>Add Book</title> </head> <body> <?php $errors = array(); // validate isbn if (empty($_POST['isbn'])) { $errors[] = 'You did not enter the books ISBN.'; } else { $isbn = trim($_POST['isbn']); } // validate name if (empty($_POST['bname'])) { $errors[] = 'you did not enter the books name.'; } else { $bn = trim($_POST['bname']); } // validate Author if (empty($_POST['author'])) { $errors[] = 'You did not enter the author of the book.'; } else { $a = trim($_POST['author']); } // validate publisher if (empty($_POST['pub'])) { $errors[] = 'You did not enter the books publisher.'; } else { $p = trim($_POST['pub']); } // create short hand for in stock $is = $_POST['stock']; //check errors if (empty($errors)) { require_once ('http://www.richardscarrott.co.uk/PRIVATE/start.php'); $query = "INSERT INTO books (ISBN, Name, Author, Publisher, Stock) VALUES ('$isbn', '$bn', '$a', '$p', '$is')"; $result = @mysql_query ($query); if($result) { echo "<h2>$bn has been added to the database</h2>"; exit(); } else { echo "<h2>You have a system error my friend</h2>"; echo '<p>' . mysql_error() . '<br/><br/>Query: ' . $query . '</p>'; exit(); } } else { echo '<h2>An error has occured with your input</h2> <p>The following errors occurred:<br/>'; foreach ($errors as $msg) { echo " - $msg<br/>\n"; } } ?> <h2>Insert Book into database</h2> <form action="addbook.php" method="post"> <p>ISNB: <input type="text" name="isbn" size="20" maxlength="20" value="<?php if (isset($_POST['isbn'])) echo $_POST['isbn'];?>" /></p> <p>Book Name: <input type="text" name="bname" size="20" maxlength="20" value="<?php if (isset($_POST['bname'])) echo $_POST['bname'];?>" /></p> <p>Author: <input type="text" name="author" size="20" maxlength="20" value="<?php if (isset($_POST['author'])) echo $_POST['author'];?>" /></p> <p>Publisher: <input type="text" name="pub" size="20" maxlength="20" value="<?php if (isset($_POST['pub'])) echo $_POST['pub'];?>" /></p> <p>Staff Member: <input type="checkbox" name="stock" value="TRUE" <?php if (($_POST['stock']) == 'TRUE') echo 'checked="checked"';?> /></p> <p> <input type="submit" name="submit" value="Enter" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form> </body> </html> I'm pretty certain the start.php file is connecting to the database when run on it's own as it does what the book says and dispays a blank screen. but here it is just in case it helps? <?php //database access infomation // define constants DEFINE ('DB_USER', 'username'); DEFINE ('DB_PASSWORD', 'password'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'databasename'); //make connection $dbc = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) OR die('Could not connect to database: ' . mysql_error()); mysql_select_db(DB_NAME) OR die('could not select database: ' .mysql_error()); ?> Obviously the aove constants values are the real password / username etc. Has anyone got any ideas? (I'm using a hosting company so have little control over what I do with the MySQL installation) Any help would be much appreciated Cheers!
-
Flash in browsers
Ok cool, thanks for your help.
-
Flash in browsers
Hi people, just interested as to whether Flash functions differently in different browsers. I.e does flash cause similar problems that HMTL can such as firefox displaying a site differently to Opera or IE? Basically are all Flash plug-ins the same on different browsers and OS's? Cheers Rich
-
css layers vs static pages
Is this confusion not all dreamweavers fault, because it strangely calls divs 'layers' and allows you to draw them onto the canvas much like photoshop. It also lets you choose when to show and hide the divs on click with some script. I would recommend leaving dreamweaver well alone when first starting out!
-
Wave goodbye to the mouse
Just had a go, it works although it's almost certainly a gimmick. It works in a very similar way to the 'Eye-toy' on the Playstation. & all I know is my arms are now aching, whilst it is very clever I don't think this its quite a replacement for the mouse!
-
PHP mail
Awesome thanks Thomas I have read about implode and explode before but never really 'got' what they were used for! Cheers.
-
PHP mail
Thanks but I know how to send that. What I need to do is send an ARRAY variable in an email. I need to print each array element in the email. Just as the foreach loop does in the webpage. I assume this would be done by putting the array in the $body but I do not know how to do this. OR If someone knows how to put the values of an array into a single variable (as a string) that would do the job because this single variable could then go into $body of the mail() function
-
PHP mail
Hi people, I have a PHP form which collates a bunch of infomation form the user and then stores it in an array. I now need to send the array in an email. I know how to print the array using foreach ($package as $selection) { echo " - $selection<br/>\n"; } But I cannot work out how I can put that into $body so it can be emailed? Does anybody have any idea? Cheers Rich
-
Validation Problem
What kip said ^, I can't remember who's blog it was off.
-
Validation Problem
ah that makes sense, well spotted. Cheers
-
Validation Problem
This site uses valid strict XHTML and doesn't use fieldset!
-
Validation Problem
Ahh that worked, thanks! I never knew <fieldset> was a required element of a form? I'm almost certain I have other forms validating on other websites without it?
-
Please Review My Site Re-design
I saw this site previously, Its proper class, I wish my design skills were on par with yours!
-
Html Form Help?
thanks for your help people, I've given up using the radio buttons and gone for annoyingly un-customisable select menus instead. here