-
Posts
75 -
Joined
-
Last visited
Never
Everything posted by Drewdle
-
I have a user database so members can log in to my site, what I want to do is when they first login, I want a message to pop up for them to confirm they have read something, but once they confirm it has been read I don't want it to pop up anymore after that, how would I do that? Thanks
-
I've read most of them...it confuses me a bit.
-
I'd like some help understanding how to use validation for form field characters please! if(!preg_match("/^[a-zA-Z]+$/",$_POST['fname'])) { echo "Invalid Entry"; } Now, where do I specify what characters to check? Is it this part: ("/^[a-zA-Z]+$/",$_POST['fname']) How would I add other things? I believe that allows upper and lower case letters only, how would I add things like '@' '-' '_' etc etc...would I just add them to the list inside the square brackets or is it a new set of brackets?... What about numbers? Would it be "/[0-9]/" ? Also, can I swap $_POST['fname'] with just a plain variable ($fname)?. (oh and does it need the '/' inside each quote?) Thanks! OH and also! if I was to check several fields, and if all is ok execute a script would I need to have elseif/else statements of could I have a new if statement for each and then just run the script below it? Thanks again!
-
Yep, I've done it. Took a while, but I did it. I was hoping for an easier way lol.
-
Thanks, your a saviour!
-
I have this script running: <?php $query = mysql_query("SELECT * FROM jobs WHERE event = 'Yes' ORDER BY title"); while ($row = mysql_fetch_array($query)) { ?> How do I check if a field is empty and NOT display it...? For instance it has a 'applied' field, if that is empty I dont want it to display, however I still need the event = 'Yes' part.
-
Lol. Your thinking about it now aren't you? Giving your kettle a small hard drive, just big enough to hold a script to turn it on when you click a button on your computer?... Or something like that anyway...
-
I swear the help I've had on here is second to none. It seems php can do damn near anything...don't suppose you have a snippet to make it make me a cup of tea do you?...Lol. Thanks man!
-
Is there a way to add a date of birth into a mysql but display it as the age?... e.g Mysql = 04/06/89 Display = 21
-
I'm trying to implement a system on my site where users can apply for 'jobs'. The job would be placed in a mysql via a form, then displayed on a page, from there I want to add a link where users can apply to do the job and then I would be able to view who applied for what job. I'd like direction to the best way of doing something like this? Thanks.
-
It was defined in the included file as something else but ive changed it now incase that was the problem...still wont store the url? <?php include ('base.php'); $id = $_GET['id']; if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "imgs/pictures/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } $file = $_FILES["file"]["name"]; mysql_query( "UPDATE `chillp_security`.`staff` SET `picture` = \'imgs/pictures/$file\' WHERE `staff`.`id` = $id"); ?>
-
Can anyone tell me whats wrong with this: The file uploads fine, the url however does not get posted to the database? I added a 'or die' but it didn't execute...Do I need to move the query higher up the script? <?php include ('base.php'); $id = $_GET['id']; if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "imgs/pictures/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } $file = $_FILES["file"]["name"]; $sql = "UPDATE `chillp_security`.`staff` SET `picture` = \'imgs/pictures/$file\' WHERE `staff`.`id` = $id;"; ?>
-
What's the best way to do previous employer form: It would have field like: Company Name | Position Held | Date Started | Date Ended | Company Address The only problem I have is Joe Bloggs might have 7 previous jobs and Fred Biggins might have only 3 previous jobs... How would I create a table for such a form? Would I have to have them enter each job one at a time and create an add row query?... I think I could add a hidden username field so when I call it back it would display only those rows relevant to that username....
-
Don't suppose you have a trick up your sleeve for creating and displaying forms with an unknown entry value?...or a trick to make my below guess easier? To explain further its a previous employers form, so it would have fields like: Company Name | Position Held | Date Started | Date Ended | Company Address The only problem I have is Joe Bloggs might have 7 previous jobs and Fred Biggins might have only 3 previous jobs... How would I create a table for such a form? Would I have to have them enter each job one at a time and create an add row query?... I think I could add a hidden username field so when I call it back it would display only those rows relevant to that username.... I dont expect you to provide the code, just guidance towards the proper method!
-
Genius. I was looking at string replace functions and all that riff raff but that one liner is perfect! Thanks!
-
I've got a form on my site, with a textbox...and the info is sent to a db. How would I get the textbox info to be displayed the same as it was entered? For instance if I put in an address: 11 Street Town City PostCode It gets displayed like: 11StreetTownCityPostCode How could I have it so when I press enter it actually adds a <br> or something to the db? Thanks.
-
No you didn't overlook them...I did. Feel free to slap me with a wet fish. Thanks.
-
I have corrected my mistake of input id/name not matching the post on the contact number field, still has the same result as above.
-
The following script doesn't seem to work? I re-used a registration script that I have which works fine, just changing the details where necessary but it doesn't work and shows no errors, when I fill out the form and click submit it just displays the form again, no success message, no error message and it doesn't add the info into the database, however when I run the same query through phpmyadmin it works... <?php include ('header.php'); ?></center> <div class=content> <?php if(!empty($_POST['username']) && !empty($_POST['password'])) { $fname = mysql_real_escape_string($_POST['first']); $lname = mysql_real_escape_string($_POST['last']); $email = mysql_real_escape_string($_POST['email']); $sia = mysql_real_escape_string($_POST['sia']); $no = mysql_real_escape_string($_POST['number']); $checknumber = mysql_query("SELECT * FROM staff WHERE no = '".$no."'"); if(mysql_num_rows($checknumber) == 1) { echo "<b>Error</b>"; echo "Mobile number in use by another employee!"; } else { $addstaff = mysql_query("INSERT INTO staff (fname, lname, email, no, sia) VALUES('".$fname."', '".$lname."', '".$email."', '".$no."', '".$sia."')"); if($addstaff) { echo "<b>Success!</b>"; echo "Employee added to the database, click <span class=1><a href=stafflist.php>here</a></span> to view employee's"; } else { echo "<b>Error</b>"; echo "<p>There was a problem adding the employee, please try again.</p>"; } } } else { ?> <b>Add an Employee</b> <br><br> Please enter the details below to add an employee to the database. <br><br> <form method="post" action="addstaff.php" name="addstaffform" id="addstaffform"> <table width=700px border=0 cellspacing=10><tr><td valign=top><table border=0> <b>Required Information:</b><br><br> <tr><td> <b>First Name:</b> </td><td> <input type="text" name="first" id="first" /> </td></tr><tr><td> <b>Last Name:</b> </td><td> <input type="text" name="last" id="last" /> </td></tr><tr><td> <b>Email Address:</b> </td><td> <input type="text" name="email" id="email" /> </td></tr></table></td><td valign=top> <table border=0> <b>More Information:</b><br><br> <tr><td> <b>SIA License Number:</b> </td><td> <input type="text" name="sia" id="sia"> </td></tr><tr><td> <b>Contact Number:</b> </td><td> <input type="text" name="no" id="no"> </tr></td></td> </table> </td></tr> </table> <input type="submit" name="add" id="add" value="Add Employee" class=btn /> </form> <?php } ?> </div> <?php include ('footer.php'); ?> I don't understand it? Whats wrong with it?
-
@dragon_sa Cheers for the mistake find, changed it! @thorpe I know, but with it being in a separate file I forget what variables I've set :l Lol. When its done I intend to re-create but with variables all being set in one file and including it. However I still get the Resource #6 error!
-
Nope, just an included nav and footer but they dont contain any php? :l Well no queries anyway... Nav: <table width=100% border=0 cellspacing=5 cellpadding=5> <tr> <td width=160 valign=top> <div class=nav> <b>Navigation</b><br><br> <span class=class1><a href=index.php>Main</a></span><br> <span class=class1><a href=about.php>About</a></span><br> <span class=class1><a href=faq.php>FAQ</a></span><br> <span class=class1><a href=contact.php>Contact</a></span> </div> <br><br> <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { ?> <div class=nav> <b>User Navigation</b><br><br> <span class=class1><a href=viewprofile.php?username=<? echo $_SESSION['Username']?>>Your Profile</a></span><br> <span class=class1><a href=editprofile.php?username=<? echo $_SESSION['Username']?>>Edit Your Profile</a></span><br><br> <span class=class1><a href=viewmembers.php>Member List</a></span><br> <span class=class1><a href=logout.php>Logout</a></span><br><br> <span class=class1><a href=admin.php>Admin?</a></span><br> </div> <?php } else { ?> <div class=nav> <b>User Navigation</b><br><br> <span class=class1><a href=register.php>Register</a></span><br> </div> <?php } ?> </td> <td valign=top> <center>
-
Excuse the mess its in, been doing php for about a week, its all trial and error learning atm! <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { ?> Welcome, <?=$_SESSION['Username'] ?>!<br> <?php } elseif(!empty($_POST['username']) && !empty($_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $password = md5(mysql_real_escape_string($_POST['password'])); $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'"); if(mysql_num_rows($checklogin) == 1) { $row = mysql_fetch_array($checklogin); $email = $row['EmailAddress']; $_SESSION['Username'] = $username; $_SESSION['EmailAddress'] = $email; $_SESSION['LoggedIn'] = 1; echo "Success!"; echo "<script type=text/javascript> // The time out value is set to be 10,000 milli-seconds (or 10 seconds) setTimeout(' document.location=document.location' ,2000); </script>"; } else { ?> <meta http-equiv="refresh" content="2;index.php"> Error: Account does not exist. <?php } } else { ?> <form method="post" action="index.php" name="loginform" id="loginform"> <b>Username:</b> <input name="username" type="text" id="username" class="box"> <b>Password:</b> <input type="password" name="password" id="password" class="box"> <input type="submit" name="login" id="login" class=btn value=Login> </form> <?php } ?>
-
Tried that: <?php $query1 = mysql_query('SELECT * FROM users ORDER BY Username'); ?> <table cellspacing="3" cellpadding="3"> <?php $result1 = mysql_query($query1) or die("There was a problem with the SQL query: " . mysql_error()); if($result1 && mysql_num_rows($result1) > 0) { $i = 0; $max_columns = 3; while($row1 = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row1); // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product if($row1['Username'] != "" && $row1['Username'] != null) echo "<td><b>Username: <? echo ['Username'] ?> <br><b>Group:</b><? echo ['Level'] ?><hr></td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } ?> </table> ?> And got: There was a problem with the SQL query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #6' at line 1 Line 1 is an include that includes a file which also runs a query.
-
I have a problem displaying the results of a table, It shows them in one long list and I'd like them to show as 2 or 3. I had a look around and the most favoured way to this I found was to split the results either by odd/even or using percentages but Im having trouble implementing it into my script. How would I go about adding the odd/even way to this: <?php $query = mysql_query('SELECT * FROM users ORDER BY Username'); while ($row = mysql_fetch_array($query)) { if ($row['UserID']) ?> <b>Username:</b> <span class=class1><a href="aeditprofile.php?username=<? echo $row['Username'] ?>"><? echo $row['Username'] ?></a></span><br> <b>Group:</b> <? echo $row['Level'] ?></color><br /><hr> <?php } ?> Essentially I'm after getting something like this: Name Name Name Group Group Group and so on down the page....
-
Grr, once again the error was on my part. I had a lowercase where I needed a capital letter. Still, I wouldnt mind learning to do this using the numeric way you mentioned if you wouldn't mind teaching me?