Jump to content

WilliamNova

Members
  • Posts

    41
  • Joined

  • Last visited

WilliamNova's Achievements

Member

Member (2/5)

0

Reputation

  1. Can't believe I didn't notice that. Removing the comma did the trick. Thanks.
  2. I'm trying to complete a page where, when you click a button, it'll change a column from 0 to 1. I copied the code form another page of mine that's similar. I just changed the variables to match what I'm trying to change, so I'm not sure why it's not updating. delete_schedule.php <?php include ('./include/header.php'); $schedule_id = $_GET['schedule_id']; include ('./include/functions/deleteScheduleFunction.php'); ?> <div id="indexContainer"> <?php include ('./include/navigation.php'); ?> <div class='header'> Are You Sure? </div> <div class='indexBox'> Please confirm that you wish to delete this schedule. If you only need to edit the schedule you do not need to delete it, <a href=''>you can edit it here</a>.<br /> <br /> <form action='' method='POST'> <input type='hidden' name='deleted' value='1' /> <input type='submit' name='update' value='I am sure - Delete this schedule' /> </form> </div> <?php include ('./include/footer.php'); ?> </div> deleteScheduleFunction.php <?php if (isset($_POST['deleted'])) { $deleted = mysql_real_escape_string($_POST['deleted']); // Update mysql_query("UPDATE schedules SET deleted='1', WHERE schedule_id='$schedule_id'"); header("Location: home.php"); } ?>
  3. Okay, I figured it out. I changed the radio input fields to select/option fields and now it works perfect.
  4. Also, I have used error_reporting(E_ALL|E_STRICT); And nothing...
  5. Wasn't sure how to word the subject. Anyways, I have a form that is supposed to update multiple fields at once. Howevever, it's only updating the first one and that's gender. It will not update Location, or About or anything else. Here's the function that's in an include file. <?php if (isset($_POST['gender'])) if (isset($_POST['location'])) if (isset($_POST['about'])) if (isset($_POST['twitter'])) if (isset($_POST['facebook'])) { $gender = mysql_real_escape_string($_POST['gender']); $location = mysql_real_escape_string($_POST['location']); $about = mysql_real_escape_string($_POST['about']); $twitter = mysql_real_escape_string($_POST['twitter']); $facebook = mysql_real_escape_string($_POST['facebook']); // Update mysql_query("UPDATE users SET gender='$gender', location='$location', about='$about', twitter='$twitter', facebook='$facebook' WHERE user_id='$user_id'"); } ?> Here's the form <form action='home.php' method='POST'> <b>Gender:</b> <?php echo "$gender"; ?><br /> <input type='radio' name='gender' value='Male' />Male <input type='radio' name='gender' value='Female' />Female<br /> <br /> <b>Location:</b><br /> <textarea name='location' value='location' class='ta3'><?php echo "$location"; ?></textarea><br /> <br /> <b>About:</b> (150 chars or less)<br /> <textarea name='about' value='about'><?php echo '$about'; ?></textarea><br /> <br /> <b>My Twitter:</b><br /> @<textarea name='twitter' value='twitter' class='ta4'><?php echo "$twitter"; ?></textarea><br /> <br /> <b>My Facebook:</b><br /> facebook.com/<textarea name='facebook' value='facebook' class='ta4'><?php echo "$facebook"; ?></textarea><br /> <input type='submit' name='submit' value='Update' /> </form>
  6. Okay, I'm an idiot. I opened Chrome and it worked perfect. Then I realized I have an ad filter on Firefox and since I used the word 'ad' on the div, it blocked the image.
  7. I have no idea what I could be doing wrong. It's incredibly frustrating considering I've never had this problem. And more so, since I'm designing another website that has the SAME EXACT CSS for these divs. Anyways, the image will not show up. I have made sure the path is correctly spelled and that images folder exists. I have made sure the class names in both home.php and main.css are spelled correctly and match. home.php <div id="container"> <div class="adContainer"> <div class="ad"> <img src="./images/ad.png" width="600" height="100" /> </div> </div> </div> main.css #container { width: 1000px; background-color: #FFF; } .adContainer { margin-bottom: 10px; } .ad { border-top: 0px; margin-bottom: 10px; padding: 10px; height: 100px; width: 800px; }
  8. There's no PHP errors given. It's simply not inserting into the table. Which is why I believe I messed up somewhere, either accidentally added a character into something or removed one while I was editing the code.
  9. And for what it matters I have tried using die(mysql_error()); which gives me nothing and I always receive "Registered Successfully!"
  10. So I have a registration form for 'users' and another registration form for 'artists' and only one works, being the 'users' one. However, all I did for 'artists' was copy the same code from 'users' and then change what needed to be changed so it would insert into the 'artists' table and not the 'users' table. I just can't find where I messed up while doing this. $error = ""; if (@$_POST['register']) { $artistname = strip_tags($_POST['artistname']); $location = strip_tags($_POST['location']); $genre = strip_tags($_POST['genre']); $email = strip_tags($_POST['email']); $password = strip_tags($_POST['password']); $password2 = strip_tags($_POST['password2']); if ($artistname == "") { $error = "Artist Name cannot be left empty."; } else if ($location == "") { $error = "Location cannot be left empty."; } else if ($genre == "") { $error = "Genre cannot be left empty."; } else if ($email == "") { $error = "Email cannot be left empty."; } else if ($password == "") { $error = "Password cannot be left empty."; } else if ($password2 == "") { $error = "Repeat Password cannot be left empty."; } $check_email = mysql_query("SELECT email FROM artists WHERE email='$email'"); $numrows_email = mysql_num_rows($check_email); if ($numrows_email != 0) { $error = 'That email has already been registered.'; } else { //Register the user $register = mysql_query("INSERT INTO artists VALUES('','$artistname,'$location','$genre','$email','$password','','','no')"); die('<p style="padding: 10px;" /><b>Registered successfully!</b><br /><br /> <a href="artistlogin.php">Login now ></a></p>'); } } ?> <form action='artistsignup.php' method='POST' style='padding:10px;'> Artist Name:<br /> <input type='text' name='artistname' value='' onclick='value=""'/><p /> Location:<br /> <input type='text' name='location' value='' onclick='value=""'/><p /> Genre:<br /> <input type='text' name='genre' value='' onclick='value=""'/><p /> Email:<br /> <input type='text' name='email' value='' onclick='value=""'/><p /> Password:<br /> <input type='password' name='password' value='' onclick='value=""'/><p /> Repeat Password:<br /> <input type='password' name='password2' value='' onclick='value=""'/><p /> <input type='submit' name='register' value='Register' /> <?php echo $error; ?> </form>
  11. I know undefined variables are simple to fix, but I can't seem to get this fixed at all. <?php include ("./inc/headerinc.php"); mysql_connect("localhost","root",""); mysql_select_db("mid"); $email = $_GET['email']; $check_email = mysql_query("SELECT * FROM users WHERE email='$email'"); $count = mysql_num_rows($check_email); if ($count == 1) { while ($row = mysql_fetch_assoc($check_email)) { $id = $row['id']; $firstname = $row['firstname']; $lastname = $row['lastname']; $email = $row['email']; $password = $row['password']; echo "<h2>$firstname's Profile</h2><br /> Name: $firstname $lastname<br /> Email: $email "; } } ?> In line 7 'email' is undefined. When I try using isset($_GET ['email']) the error goes away, but none of the information that's suppose to echo is displayed.
  12. $data = mysql_query("SELECT * FROM news") or die(mysql_error()); $info = mysql_fetch_array( $data ); while($info = mysql_fetch_array( $data )) This is what I have thus far. Which all works just fine and when I use print it displays the correct fields, so I know the database is connected and is relaying information fine. I guess I'm not sure where I put this hand dandy code. <div id="news"> <div class="newsBody"> <div class="newsHeader"> <div class="newsDate"> Posted: <?php echo"$date"; ?> </div> <div class="newsAuthor"> Posted By: <?php echo"$author"; ?> </div><br /> <?php echo"$subject"; ?> </div> <div class="newsSynop"> <?php echo"$body"; ?> </div> </div> </div> I want to have those variables echo the database values. So I can't figure out how to get the info for author in Posted By: <?php echo"$author"; ?> and same with date, subject, body.
  13. So, I'm trying to display information from a table into my database on one of my pages. However, everything I've tried isn't working. Obviously, it's me. I know I'm doing something wrong, just not sure what. I deleted the PHP code related to querying and getting the information, again it was obviously done wrong anyways. So I have a table named 'news' and I have some columns, named 'author', 'date', 'subject', 'body'. I have some areas where I want those values displayed on my website in $author $date $subject $body Seems like whenever I alter the code I always have a new problem. I'm still learning PHP, so please don't just give me the code, I want to LEARN it, so if anything if you could break it down, that would be great and I hope it's not asking for a lot.
  14. I'm using md5 only because I'm new to this. I simply googled "how to encrypt passwords" and found a website tutorial pertaining to that. I know md5 isn't very secure, it was only for learning and I do plan on getting something better. But for now it will do since my website isn't even online and there's one user (me). The login logic makes sense since I scripted the encryption after both scripts were made and only modified the signin script. But I'll definitely look into crypt() and password_compat
  15. Still having some issues on my scripts. This time when I register a new user, which works fine, then I attempt to login into that user on the webpage, it doesn't go through, but if I go into my database and copy the column with the password that's been encrypted and paste it into the password field on the webpage, it works. I do have my script using md5 to encrypt the passwords the user sends to the database. I'm also salting for further security. <?php error_reporting(E_ALL); $error = ""; if ($_POST['register']) { $date = date("Y,-m-d"); $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $username = strip_tags($_POST['username']); $email = strip_tags($_POST['email']); $password1 = strip_tags($_POST['password']); $password2 = strip_tags($_POST['passwordrepeat']); $day = strip_tags($_POST['day']); $month = strip_tags($_POST['month']); $year = strip_tags($_POST['year']); $dob = "$day/$month/$year"; if ($firstname == "") { $error = "First Name cannot be left blank."; } else if ($lastname == "") { $error = "Last Name cannot be left blank."; } else if ($username == "") { $error = "Username cannot be left blank."; } else if ($email == "") { $error = "Email cannot be left blank."; } else if ($password1 == "") { $error = "Password cannot be left blank."; } else if ($password2 == "") { $error = "Repeat Password cannot be left blank."; } else if ($day == "") { $error = "The day of your birthday cannot be left blank."; } else if ($month == "") { $error = "the month of your birthday cannot be left blank."; } else if ($year == "") { $error = "The year of your birthday cannot be left blank."; } // Check for username existence. $check_username = mysql_query("SELECT username FROM users WHERE username='$username'"); $numrows_username = mysql_num_rows($check_username); if ($numrows_username != 0) { $error = 'That Username is already taken.'; } else { $check_email = mysql_query("SELECT email FROM users WHERE email='$email'"); $numrows_email = mysql_num_rows($check_email); if ($numrows_email != 0) { $error = 'That Email is already registered.'; } else { $salt1 = "great"; $salt1 = md5($salt1); $salt2 = "white"; $salt2 = md5($salt2); $salt3 = "void"; $salt3 = md5($salt3); $password1 = $salt1.$password1.$salt3; $password1 = md5($password1.$salt2); $password2 = $salt1.$password2.$salt3; $password2 = md5($password2.$salt2); if ($password1 != $password2) { $error = 'The Passwords do not match.'; } else { // Register the user $register = mysql_query("INSERT INTO users VALUES('','$firstname','$lastname','$username','$email','$password1','$dob','$date','no','')"); if(!$register){ die(mysql_error());} die("<h2>Success!</h2>"); } } } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.