
LunarIsSexy
Members-
Posts
19 -
Joined
-
Last visited
Everything posted by LunarIsSexy
-
How to validate contact form using java script?
LunarIsSexy replied to MathiVel's topic in Javascript Help
Yes but its always good to be double-careful Plus if you don't use JS than it isn't very interactive and it keeps it basic. -
How to validate contact form using java script?
LunarIsSexy replied to MathiVel's topic in Javascript Help
I think he means checking if the user actually input anything in the field when they press submit. If they didn't input anything it shows an error message on top of that field. This would be done with JavaScript, not PHP. -
I am not looking for somebody to make scripts for me as thats not the point of this topic this topic is meant for help with topics that are related to PHP. I was wondering if there was anybody who is pretty good with PHP that would be able to write 10 pages of lessons from beginning to end like I have in my examples below. I will proof-read them to make sure they're good and then you will be paid for writing them. This is me asking for help that is PHP related so please don't complain. Examples: http://gyazo.com/21c86d73a59b9a3993472b8193647889.png http://gyazo.com/6a988bc22013422b1d5c0c902c1c9071.png Message me or email me! Email: harrison.kevin@hotmail.com
-
So I am making a basic Q&A Forum right quick. I made it so that it correctly stores the post title, content, author, etc... I'm just wondering how I could make it display all those on one single page using PHP without having to input each individually. I was thinking of doing something with the auto incremented ID but I'm not quite sure. Im familiar with PHP and SQL so its fine if you're blunt about it. I would also like to make some way to paginate this to limit 10 per page, anyone got any clue about this? It would be much appreciated!
-
Super nested ifs - Better as switches? Multiple logic expressions
LunarIsSexy replied to brentman's topic in PHP Coding Help
A quicker and much neater way to do it would be like this atleast in my opinion it is. if ($number = 5) { //not allowed } else if ($letter == a) { //not allowed } else if ($option > 2) { //not allowed } else { echo "ALLOWED"; } } } The way you're doing it is just fine and it really depends on which way is easier for you to understand. Its all about preference as both of them will give you the same output. -
The data wouldn't update in the database at all because there was no default data for that ID. When I updated it I was updating it based on whatever column had the ID field matching the session ID. Idk how else to do it so I just set a default by clicking insert in PHPMyAdmin. Any ideas?
-
I made it so when you register it will just set your ID inside the table and set the lastpage as page1.php. This is a very weird way to do it but it works out! Thanks for all your guys help!
-
That got rid of the error but this code still doesn't work. This is what I have 100% and nothing happens. Blank page and nothing shows up in database. <?php include 'connect.php'; include 'main.php'; $id = $_SESSION['id']; $page = "http://localhost/page1.php"; $sql = "UPDATE html SET id='$id', lastpage='$page' WHERE id='$id'"; mysql_query($sql) or die("MYSQL Query Failed : " . mysql_error()); $result3 = mysql_query("SELECT * FROM html WHERE id='$id'") or die("MYSQL Query Failed : " . mysql_error()); while($row3 = mysql_fetch_array($result3)) { $lastpage=$row3['lastpage']; echo $lastpage; } ?>
-
Thankyou for that! It now debugs saying this. MYSQL Query Failed : 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 '://localhost/page1.php WHERE id='8'' at line 1 I think this is due to the fact that there are no values or anything data saved under html, so it can't find anything with the ID 8. Any idea what to do next? I guess instead of updating its going to have to just add a new one and if there is already something with that ID it will just update it. Any idea?
-
I'm not very great with PHP but this would be the correct function to call a debug on a variable right? <?php function debug_view ( $page ) { echo '<pre>'; if ( is_array( $page ) ) { print_r ( $page ); } else { var_dump ( $page ); } echo '</pre>'; } ?> At the moment I don't have any debug code.
-
So this is my code and for some reason nothing displays on the screen at all. It should echo $page or $latestpage and that should be a link it saved in the database but it didn't save anything to the database and it didn't echo anything. Any clue? <?php include 'connect.php'; include 'main.php'; $id=$_SESSION['id']; $page = "http://localhost/page1.php"; $sql="UPDATE math SET latestpage=$page where id='$id'"; mysql_query($sql); $result3 = mysql_query("SELECT * FROM html where id='$id'"); while($row3 = mysql_fetch_array($result3)) { $latestpage=$row3['latestpage']; echo $latestpage; ?>
-
That made me think of something. What if I were to make a table for Math and then structure it with ID for the users ID and set it to Varchar without AI because its just grabbing the data from a different table. Another one saying latestPage. Then say you goto Page2 it will do this: $page="http://localhost/page2.php" $sql="UPDATE math SET id="$_SESSION['id']", latestPage="$page" where id='$id'"; mysql_query($sql); Just a quick example. Basically each page I would just change $page to the page its on. Then if you exit and come back to continue it'll do this require_once('connect.php'); $id=$_SESSION['id']; $result3 = mysql_query("SELECT * FROM math where id='$id'"); while($row3 = mysql_fetch_array($result3)) { $latestPage=$row3['latestPage']; Then the link to continue would be simply like this: href="<?php echo $latestPage?>" The only question I have is before it saves the page into the database could I make it check to see if their latest page was a certain link, and if it was to go on with the function. Any ideas?
-
I have a hard question that hopefully somebody could help me with. I'm trying to make a website that teaches tutorials on certain subjects and lets just say your on page 5 in the subject "Math" and there are 20 pages in total in that subject I could just make it at the top of Page 5 set the $_SESSION = 25 for example. How would I then make it so this always automatically saves to the database but also make it so you need to be equal to or over the percentage of 50 to get to page 10/20 for example. I know that I can just do an if statement checking if the percentage is but I want to make it always automatically save to the database what percentage and I want it so that if the user signs in on a different computer it will still have the same amount of percentage. You don't have to add it but if someone were able to figure out also how to add so that when you press "Continue" on the homepage under the subject it would actually bring you to the page matching the percentage you have. I know this is a lot of work but if somebody could atleast point me in the right direction, thankyou <3 I already have a login and register system, so I could incorporate it into the users table but that might make things get confusing if I have up to 10 subjects.
-
I have the Varchar set to 1024, thats it. I can save about 50 letters worth of text and if I go over it won't save at all. How would I go about making to so max is 400 chars?
-
I always thought Varchar's were what controlled the maximum amount of characters or data that could be stored in that structure. I was wondering what I should set the Varchar to for something like a Bio. 400 characters minimum. I might be wrong about it, but I hope I'm not because I have it set to 1024 right now and whenever I update my bio if it is really long like over 50 characters it won't save.
-
Thats what my friend said D: I would ask him what he means but then he'd think I'm retarted. I know what mysqli is, instead of doing for example mysql_connect do "mysqli_connect", etc... But what do you mean by PDO?
-
Update: The image its showing up with is a link to the folder 15, not inside /site_images/ and without the image name. D:
-
I'm very bad with checking Syntax and I confused myself here D: Anybody able to help? Function: <?php require('main.php'); require('connect.php'); $id=$_SESSION['id']; $result3 = mysql_query("SELECT * FROM photo where id='$id'"); while($row3 = mysql_fetch_array($result3)) $image=$row3['filename']; ?> Calling the image: <img src=" <?php if(empty($image)){ echo "upload/your-photo.jpg"; }else{ echo "site_images/" + $id + "/" + $image; }?>" alt="" width="85" height="85"> Basically it will save the file uploaded into the database with the filename and the id of the user, it will then make a directory inside site_images named after the ID of the user and it will move the image to that folder. Then to show the image I made it check if the user never uploaded a photo, and if they haven't to show the default. If they have uplaoded a photo it will set the source of the images to "site_images/$id/$image" basically. This works perfectly if I put it like this. <img src="/site_images/<?php echo $id ?>/<?php echo $image ?>"> Any idea what I did wrong or whats wrong with my syntax?
-
Thankyou! I forgot to reply saying I figured it out but thanks for your guys help, I didn't notice you commented. You were right @TOA, I forgot to fire the query. I didn't notice til I stared at it for a while, but others with this problem just add $mysql_query($sql); after the Update.
-
This is just a basic script for updating my database from form data. I don't have much experience with databases and this might be a bad question but I have read online that you should use UPDATE because I've only ever inserted stuff to tables. Any idea whats wrong here? <?php include 'connect.php'; include 'main.php'; if(!isset($_SESSION['id'])) echo "You need to login to view this page"; else{ } $id = $_SESSION['id']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $motto = $_POST['motto']; $bio = $_POST['bio']; if(empty($firstname) || empty($lastname) || empty($motto) || empty($bio)){ echo "You didn't fill out any fields."; } else if (strlen($motto) < 5) { echo "Your motto must be more than 5 characters."; } $sql="UPDATE users SET firstname='$firstname', lastname='$lastname', bio='$bio', motto='$motto' WHERE id='$id'"; ?> There are no errors that show up when its loaded because I fixed some of the other ones but obviously I didn't put for there to be text saying like "Update complete!" or whatever. But I wasn't sure if I should do and "else" around the $sql function. It looks like it should work in my eyes but it doesn't update them. Database: http://gyazo.com/b381e32d655f615b189e4fa46b74fa46.png I do have it connected properly as I already have a register system, profile page, etc... Also if anyone is good with SQL what should the Varchar be for the BIO? I just set 1024, but I have no clue :/