Jump to content

terryds

Members
  • Posts

    174
  • Joined

  • Last visited

Everything posted by terryds

  1. SOLVED! The bindValue(':message', $msg) should be (':msg', $msg)... I'm sorry not checking this before....
  2. I want to save data filled in my form to my MySql database. But, it throws an error..Look at my savedata.php code : try{$pdo = new PDO('mysql:host=localhost;dbname=mydbname', 'me', 'mypassword');$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);$pdo->exec('SET NAMES "utf8"');}catch (PDOException $e){$error = 'Error connecting to database: ' . $e->getMessage();echo $error;exit();} try{$name = $_POST['name'];$email = $_POST['email'];$msg = $_POST['msg'];$sql = 'INSERT INTO fansSET name = :name,email = :email,message = :msg';$s = $pdo->prepare($sql);$s->bindValue(':name', $name);$s->bindValue(':email', $email);$s->bindValue(':message', $msg);$s->execute();} catch (PDOException $e){$error = 'Error saving data: ' . $e->getMessage();echo $error;exit();} echo 'Succeed to saving your data. Hello, ' . htmlspecialchars($name, ENT_QUOTES, 'UTF-8');?> My form html code <form action="script/savedata.php" method="post"><label for="name">Name</label><br><input type="text" name="name"><br><label for="email">Email</label><br><input type="email" name="email"><br><label for="msg">Message</label><br><textarea name="msg"></textarea><br><input type="submit" name="submit" value="Send!"></form> The error goes like this : Error saving data: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined Can you help me fix this error ?
  3. I think the {$parent} should be with no curly brackets... Correct me if i'm wrong...
  4. Can you tell me what the function of PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ?I've read the php manual, but i still dont understand that...If i remove the setattributte method, it looks alright too... What's the function of that actually ?
  5. terryds

    PHP Closing Tag

    I see some php files contain the ?> closing tag, but some don't... What's the difference between putting it and not putting it ?
  6. I'm looking for an ebook containing how to build web applications (like blog, bulletin board, social network, etc.)..Can you tell me what ebook is it?
  7. Can you tell how to redirect the phone to its mobile version using MobileESP ?
  8. I see there is a javascript statement like this : [color=#000000]<!--[/color][color=#000000]if (screen.width <= 700) {[/color][color=#000000]window.location = "http://m.yourdomain.com";[/color][color=#000000]}[/color][color=#000000]//-->[/color] [color=#000000] [/color] Can you tell me what does the <!-- //--> mean ? Is it a comment? But.. if it's a comment, so the statement inside won't be executed, right? I know that code from http://www.webhostinghub.com/support/website/how-to/mobile-redirect
  9. Look at this first! The input for name and email arent in the same indent.. How to make their same indent ? HTML code <form action="contact.php" method="post"><p>Name:<input type="text" name="name" placeholder="Type Here"><br>Email:<input type="email" name="email" placeholder="example@example.com"><br>Message:<br><textarea name="msg"></textarea><br><input type="submit" name="submit" value="Submit!"></p></form> CSS input[type="text"], input[type="email"] {margin-left: 50px;} Please tell me how to fix the indent...
  10. I want to make a site that automatically redirects to subdomain m.mysite.com ?I mean, i want to make a site that has two versions, one for desktop (without subdomain m. ) and one for mobile phones (with subdomain m.)When the user goes to mysite.com using his mobile phone, he will be directed to m.mysite.com.. (like facebook) Can you tell me how to do that?
  11. I'm confused what to choose between html5 and older html version... I see that html5 is great, but what if old browser and mobile phone browser can't render it? Can you tell me how to make all browsers (including mobile phone browser, like Opera mini) can render html5 and css3 ?
  12. See my code first <!DOCTYPE html><html><head><style> h1 {z-index:2;} img{position:absolute;left:0px;top:0px;z-index:1;}</style></head> <body><h1>This is a heading</h1><img src="w3css.gif" width="100" height="140" /><p>The z-index isn't working. The header should be in front of the image, but it isn't..</p></body></html> Actually the code is from http://www.w3schools.com/cssref/tryit.asp?filename=trycss_zindex , i edited the code...Does z-index not work if we put positive numbers ?
  13. terryds

    Untidy form

    Please tell me why we should use <span> tag instead of <label> tag?
  14. terryds

    Untidy form

    My html : <!DOCTYPE html><html><head><title>Sign Up Now!</title><link rel="stylesheet" type="text/css" href="signup.css" /></head><body><h1>Sign up now and get the gifts!</h1><h3>Type down your identity !</h3><form method="post" action="report.php"><fieldset><legend>Sign Up</legend><label>First Name:</label><input type="text" id="fname" name="fname" /><br /><label>Last Name:</label><input type="text" id="lname" name="lname" /><br /><label>Email</label><input type="text" id="email" name="email" /><br /><label>Country</label><input type="text" id="country" name="country" /><br /><label>Gender</label><label for="male">Male</label><input id="male" name="gender" type="radio" value="male"><label for="female">Female</label><input id="female" name="gender" type="radio" value="female"><br /><label>Why do you want to join us ?</label><textarea id="reason" name="reason"></textarea><br /><input type="submit" value="Sign Up!" name="submit" /></fieldset></form></body></html> My CSS : h1 {color: red;} legend {font-size: 20px;} label {width: 300px;float: left;text-align: left;}
  15. terryds

    Untidy form

    My form has untidy radio buttons.. Look ! The label male and female and the radio buttons are very awful.. Please help me fix this...
  16. This is my code for signup.php <!DOCTYPE html><html><head><title>Thanks for signing up!</title></head><body><h2>Wait till the admin validates your account</h2><?php$name = $_POST['fname'] . " " . $_POST['lname'];$email = $_POST['email'];$country = $_POST['country'];$gender = $_POST['gender'];$reason = $_POST['reason']; $to = 'myemail@blahblah.com';$subject = 'Admin - Validating';$msg = "$name wants to join the site.\n" . "$name 's email is $email \n" . "$name is a $gender in $country \n" . "$name wants to join because $reason";$delivery = mail ($to, $subject, $msg, 'From: ' . $email); echo 'Thanks for signing up, ' . $name . '<br />';echo 'Those datas you input will be emailed to admin' . '<br />';echo 'Name : ' . $name . '</br>';echo 'Email : ' . $email . '<br/>';echo 'Country : ' . $country . '<br />';echo 'Gender : ' . $gender . '<br />';echo 'I join this because ' . $reason;?> </body></html> This is the signup html (the form) <!DOCTYPE html><html><head><title>Sign Up Now!</title><link rel="stylesheet" type="text/css" href="signup.css" /></head><body><h1>Sign up now and get the gifts!</h1><h3>Type down your identity !</h3><form method="post" action="signup.php"><fieldset><legend>Sign Up</legend><label for="fname">First Name:</label><input type="text" id="fname" name="fname" /><br /><label for="lname">Last Name:</label><input type="text" id="lname" name="lname" /><br /><label for="email">Email</label><input type="text" id="email" name="email" /><br /><label for="country">Country</label><input type="text" id="country" name="country" /><br /><label for="gender">Gender</label><input id="gender1" name="gender" type="radio" value="male">Male<input id="gender2" name="gender" type="radio" value="female">Female<br /><label for="reason">Why do you want to join us ?</label><textarea id="reason" name="reason"></textarea><br /><input type="submit" value="Sign Up!" name="submit" /></fieldset></form></body></html> Please help me where to add the code? And how it should be ?
  17. I created a form that willl automatically send what it's filled in via email.. What is annoying is when i don't fill in the form and click submit.. The mail function also works... Can you tell me how to make it not send anything when the form isn't filled in ?
  18. I created a database named testdb via phpMyAdmin in localhost...But, i don't know how to see the database' location, username, and password... Please tell me how..
  19. I have a mail function in my signup.phpBut, i don't know how to check if the mail function works... I used this code $delivery = mail ($to, $subject, $msg, 'From: ' . $email); if ($delivery) {echo 'Your form has been sent to Admin' . '<br />';}else{echo 'Failed to send the form. Try Again' . '<br />';} I had thought that it would solve the problem.. But, it would not ! I disconnected from the internet then i opened my signup.php, click 'submit'..But, it said that the form has been sent although i had disconnected from internet.. Would you please tell me the correct code to make the function-checker work ?
  20. Thank you... Solved!I noticed there is two problems :1. The name table is missingand2. there should be no more comma on line 7
  21. Hello, everyone..I have a database named testdbI want to create a table named signup_table.. This is the code i wrote Then, an error appeared...Would someone please help me on this ?
  22. Solved !!!I have found one more mistake and it solved the problem !! This code doesn't have the equal sign... name"lname" Hahahah... I feel so ashamed..
  23. Umm.. I just notice one mistake and it doesn't fix the problem... The code <h1>Sign up now and get the gifts!<h1> Should be <h1>Sign up now ad get the gifts!</h1> Can someone please tell where the problem is for me?
  24. Hello, all! I want to create a sign-up page, then i make signup.html and signup.php ...The signup html goes well, but the signup php doesn't.. Please check what's wrong with my code... signup.html <!DOCTYPE html><html><head><title>Sign Up Now!</title><link rel="stylesheet" type="text/css" href="signup.css" /></head><body><h1>Sign up now and get the gifts!<h1><h3>Type down your identity !</h3><form method="post" action="signup.php"><fieldset><legend>Sign Up</legend><label for="fname">First Name:</label><input type="text" id="fname" name="fname" /> <label for="lname">Last Name:</label><input type="text" id="lname" name"lname" /> <label for="email">Email</label><input type="text" id="email" name="email" /> <label for="country">Country</label><input type="text" id="country" name="country" /> <label for="gender">Gender</label><input id="gender" name="gender" type="radio" value="male">Male<input id="gender" name="gender" type="radio" value="female">Female <label for="reason">Why do you want to join us ?</label><textarea id="reason" name="reason"></textarea> <input type="submit" value="Sign Up!" name="submit" /></fieldset></form></body></html> signup.php <!DOCTYPE html><html><head><title>Thanks for signing up!</title></head><body><h2>Wait till the admin validates your account</h2><?php$name = $_POST['fname'] . " " . $_POST['lname'];$email = $_POST['email'];$country = $_POST['country'];$gender = $_POST['gender'];$reason = $_POST['reason']; echo 'Thanks for signing up, ' . $name . '';echo 'Those datas you input will be emailed to admin' . '';echo 'Name : ' . $name . '';echo 'Email : ' . $email . '<br/>';echo 'Country : ' . $country . '';echo 'Gender : ' . $gender . '';echo 'I join this because ' . $reason;?> </body></html> When i fill in the form, then submit them.. Then the signup.php appears and the output is below Wait till the admin validates your account Notice: Undefined index: lname in C:xampphtdocsphpsignup.php on line 9Thanks for signing up, aaaaThose datas you input will be emailed to adminName : aaaaEmail : aaaa@aa.comCountry : aaaaGender : maleI join this because i like it Please fix this... P.S. I run it in localhost
×
×
  • Create New...