Jump to content

jon4433

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Everything posted by jon4433

  1. So I have an simple account centre up, and i'm wanting to display their 'Name' 'Username' and 'Email' as part of their details. But I have one problem... My code doesn't seem to be getting the data from my database... It may be messy to some people, just warning you! <?php session_start(); if($_SESSION['username']){ $connect = mysql_connect("****","****","****") or die("Could not connect to database."); mysql_select_db("****") or die ("Could not find database!"); $sql = mysql_query("SELECT * FROM login"); $username = $rows['username']; $email = $rows['email']; $rows = mysql_fetch_assoc($sql); echo "<p>"; } else header("location: suggestion.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> <link href="css/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { background-color: #CCC; } body,td,th { color: #000; font-family: "MS Serif", "New York", serif; } </style> </head> <body> <div id="wrap"> <!--Header--> <div id="header_member"> </div> <!--Log out and time--> <div id="info"> <div id="date"><script type="text/javascript"> var currentDate = new Date() var day = currentDate.getDate() var month = currentDate.getMonth() + 1 var year = currentDate.getFullYear() document.write("<b>" + day + "/" + month + "/" + year + "</b>") var currentTime = new Date() var hours = currentTime.getHours() var minutes = currentTime.getMinutes()</script> </div> <div id="time"><script type="text/javascript"> var suffix = "AM"; if (hours >= 12) { suffix = "PM"; hours = hours - 12; } if (hours == 0) { hours = 12; } if (minutes < 10) minutes = "0" + minutes document.write("<b>" + hours + ":" + minutes + " " + suffix + "</b>")</script> </div> </div> <div id="logout"><center><?php echo "<a href='logout.php'>Log out.</a>";?></center></div> <!--Main section which will contain everything else--> <div id="member_main"> <div id="member_right"><center> <p><img src="images/accountinf.png" width="175" height="30" /></p> <p>Name: <?php echo $username;?></p> <p>Email: <?php echo $email;?></p> </center> </div> <div id="member_top"><center><?php echo "Welcome, ".$_SESSION['username'];?></center></div> <div id="member_left" align="center"><img src="images/navigation.png" width="105" height="30" /><img src="images/home_member.png" width="105" height="30" /><img src="images/account.png" width="105" height="30" /></div> </div> <!--Footer--> <div id="footer_member"></div> </div> </body> </html>
  2. So I have 2 radio buttons, one called 'Yes' and the other called 'No'. I want the user to choose one of them since they are required, but how would I send which choice they have choosen? I have the mail form out set out of working, but i'm not too sure on how I would send the option that the user chooses. <?php if($_POST['submit']) { $username = $_POST['username']; $email = $_POST['email']; $age = $_POST['age']; $location = $_POST['location']; $duration = $_POST['duration']; $no = $_POST['no']; $yes = $_POST['yes']; //$griefed = $_POST['griefed']; $access = $_POST['access']; $builder = $_POST['builder']; $fill = $_POST['fill']; if(empty($username)){ echo "The username field was blank. Please go back and fill in the required fields.<br>"; } if(empty($email)){ echo "The email field was blank. Please go back and fill in the required fields.<br>"; } if(empty($age)){ echo "The age field was blank. Please go back and fill in the required fields.<br>"; } if(empty($location)){ echo "The location field was blank. Please go back and fill in the required fields.<br>"; } if(empty($duration)){ echo "The duration field was blank. Please go back and fill in the required fields.<br>"; } if(empty($access)){ echo "The access field was blank. Please go back and fill in the required fields.<br>"; } if(empty($builder)){ echo "The builder field was blank. Please go back and fill in the required fields.<br>"; } if(empty($fill)){ echo "The more details field was blank. Please go back and fill in the required fields.<br>"; } else{ if($username && $email && $age && $location && $duration && $access && $builder && $fill){ $to = "dtoyee@dawncraftmc.com"; $subject = "Creative World Application"; $message = "Username: $username Email: $email Age: $age Location: $location Duration on the server: $duration Access to the new world: $access Are you a good builder: $builder Anything else that we should know: $fill"; $headers = "From: $email /n"; mail($to,$subject,$message,$headers); echo "Application was sent!"; } else { echo "All fields are required!"; } } } ?> <!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> <link href="css/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { font-family: Minecraft; background-image: url(images/background.png); background-size:100% 100%; background-attachment: fixed; background-repeat: repeat-x; background-position: left top; background-color: #999999; } body,td,th { color: #FFF; } </style> </head> <body> <div id="wrap"> <!--Banner--> <div id="header_2"><a href="index.html"><img src="images/banner.png"/></a></div> <div id="error"></div> <!--White-List form--> <div id="whitelist" align ="right"> <form method="POST"> In-Game Name: <input type="text" name="username"/><p> Email: <input type="text" name="email" /><p> Age: <input type="text" name="age" /><p> Location: <input type="text" name="location" /><p> How long have you beed on Dawncraft: <input type="text" name="duration" /><p> Have you ever griefed: <label> <input type="radio" name="no" value="no" id="choice_0" /> No</label> <br /> <label> <input type="radio" name="yes" value="yes" id="choice_1" /> Yes</label><br /> Why do you want access to the creative world:<textarea name="access"></textarea><p> Do you consider yourself to be a good builder: <textarea name="builder"></textarea><p> Anything else that we should know: <textarea name="fill"></textarea><p> <input type="submit" name="submit" value="Submit" /><br /> </form> </div> <!--Footer--> <center><div id="footer_2">Dawncraft© 2011 - 2012</div></center> </div> </body> </html>
  3. I decided to do something else. Thank you anyway!
  4. I learned the script from this website http://www.w3schools.com/js/js_popup.asp. I was trying to get it so, when a user leaves a blank box in my form, a popup window pops up and says a message to them.
  5. I have some if statements in my php code, and I would like to have javascript so that I can have pop up boxes with the error on. I have been trying to work it out, but i'm getting 2 errors. It's my first time using javascript today, so I have no idea if it is correct or not. My javascript and php if statement is giving me one error. <script type="text/javascript"> if(empty($username)) { function show_alert() { alert("Please fill in the username field!"); } } </script> And i'm also getting another error with the 'style type'. <style type="text/css"> body { font-family: Minecraft; background-image: url(images/background.png); background-size:100% 100%; background-attachment: fixed; background-repeat: repeat-x; background-position: left top; background-color: #999999; } body,td,th { color: #FFF; } </style>
  6. jon4433

    Hey!

    Hello, my name is Jon. I started learning HTML and CSS around November 2011, and since then I have built my own website using HTML and CSS. I'm looking into doing some php stuff with the website too. Currently learning php! If you are interested, you can take a look at my website below! (Both links on the index page go to the same homepage for now.) http://www.dawncraftmc.com/ Looking forward to being on this forum! -Jon
  7. Thank you! They are how I want it to be now! I also have another problem... How do I attach more than one string to the message? I'm only getting the 'Username' at the moment. Edit - Figured it out! Thank you for the help!
  8. It did have a semicolon before I posted the thread. I was testing to try and get them to include each other, but I guess it didn't work, but i'll be changing them back to a semicolon soon!
  9. Hmm, what will I need to do to the mail function? I thought the mail function was correct, but i'm new at php. That is correct. It actually shows the $subject in the message area. Also, I like how fast replies are on this forum!
  10. I'm using the mail() in my application form, but I can't seem to get the email to send what the user has entered in the form to me. It's been confusing me for hours now! <?php if($_POST['submit']) { $username = $_POST['username']; $email = $_POST['email']; $age = $_POST['age']; $location = $_POST['location']; $duration = $_POST['duration']; $griefed = $_POST['griefed']; $access = $_POST['access']; $builder = $_POST['builder']; $fill = $_POST['fill']; if($username && $email && $age && $location && $duration && $griefed && $access && $builder && $fill){ $to = "dtoyee@dawncraftmc.com"; $from = '$email'; $subject = "Creative World Application" ; $message = "Username: $username /n" . "Email: $email /n" . "Age: $age /n" . "Location: $location /n" . "Duration on the server: $duration /n" . "Ever griefed: $griefed /n" . "Access to the new world: $access /n" . "Are you a good builder: $builder /n" . "Anything else that we should know: $fill /n" . mail($to, $from, $subject, $message); echo "Application was sent!"; } else { echo "All fields are required!"; } } ?> <!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> </head> <body> <form method="POST"> <center> In-Game Name: <input type="text" name="username"/><p> Email: <input type="text" name="email" /><p> Age: <input type="text" name="age" /><p> Location: <input type="text" name="location" /><p> How long have you beed on Dawncraft: <input type="text" name="duration" /><p> Have you ever griefed: <input type="text" name="griefed" /><p> Why do you want access to the creative world: <input type="text" name="access" /><p> Do you consider yourself to be a good builder: <input type="text" name="builder" /><p> Anything else that we should know: <textarea name="fill"></textarea><p> <input type="submit" name="submit" value="Submit" /> </center> </form> </body> </html>
×
×
  • 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.