Jump to content

soc86

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by soc86

  1. run the quey and $existCount is equal to 1?
  2. What do you mean application, Its coded by myself?
  3. I am trying to create a login form. But when i enter the correct username and password it will not redirect me to the correct mage (index.php). Can anyone help, my code is below: <?php session_start(); if(isset($_SESSION["manager"])){ header("location: index.php"); exit(); } ?> <?php //Parse the log in form if the user has filled it out and pressed "Log In" if(isset($_POST["username"])&& isset($_POST["password"])){ $manager=preg_replace('#[^A-Za-z0-9]#i','',$_POST["username"]); $password=preg_replace('#[^A-Za-z0-9]#i','',$_POST["password"]); //Connect to the MySQL database include"../storescripts/connect_to_mysql.php"; $sql=mysql_query("SELECT id FROM admin WHERE username='$manager' AND password='$password' LIMIT 1"); //query the person //-----MAKE SURE PERSON EXISTS IN DATABASE ----- $existCount=mysql_num_rows($sql); //count the row nums if($existsCount==1){ //evaluate the count while($row=mysql_fetch_array($sql)){ $id=$row["id"]; } $_SESSION["id"]=$id; $_SESSION["manager"]=$manager; $_SESSION["password"]=$password; header("location: ../index.php"); exit(); }else{ echo 'That information is incorrect try again <a href="admin_login.php">Click Here</a>'; exit(); } } ?>
  4. Still a problem after removing the comma, help? Error message: Query: INSERT INTO blogdata (title, category, content) VAULE('rewerw ', 'erwrr', 'rewrwer') Produced error: 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 'VAULE('rewerw ', 'erwrr', 'rewrwer')' at line 1
  5. The error message is: Query: INSERT INTO blogdata (title, category, content,) VAULE('rewerw ', 'erwrr', 'rewrwer') Produced error: 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 ') VAULE('rewerw ', 'erwrr', 'rewrwer')' at line 1 I have entered the code as: <?php mysql_connect ("localhost", "root", ""); mysql_select_db("blog"); ?> <html> <head> <title>Admin - Post new entry</title> </head> <body> <?php if( strtolower($_SERVER['REQUEST_METHOD']) === 'post' ) { $title = $_POST['title']; $category = $_POST['category']; $content = $_POST['content']; $query = "INSERT INTO blogdata (title, category, content,) VAULE('$title ', '$category', '$content')"; if( !$result = mysql_query($query) ) { echo "<br>Query: $query<br>Produced error: " . mysql_error(); } } else { ?> <form action='admin.php' method='post'> Title: <input type='text' name='title' /><br /> Category: <input type='text' name='category' /><br /> Content: <textarea name='content'></textarea><br /> <input type='submit' name='submit' value='post!' /> <?php } ?> </form> </body> </html>
  6. When my code is has it was originally, i.e. <?php mysql_connect ("localhost", "root", ""); mysql_select_db("blog"); ?> <html> <head> <title>Admin - Post new entry</title> </head> <body> <?php if(isset($_POST['submit'])){ $title = $_POST['title']; $category = $_POST['category']; $content = $_POST['content']; $sql = mysql_query("INSERT INTO blogdata (title, category, content,) VAULE('$title ', '$category', '$content')"); echo "Data has been posted, click <a href='index.php'?here</a> to see it"; }else{ ?> <form action='admin.php' method='post'> Title: <input type='text' name='title' /><br /> Category: <input type='text' name='category' /><br /> Content: <textarea name='content'></textarea><br /> <input type='submit' name='submit' value='post!' /> <?php } ?> </form> </body> </html> The post is accepted, i get a message displaying: Data has been posted, click <="" a=""> to see it When i click to view my blog there is no update?
  7. Still having problems?? <?php if( strtolower($_SERVER['REQUEST_METHOD']) === 'post' ) { $title = $_POST['title']; $category = $_POST['category']; $content = $_POST['content']; $query = "INSERT INTO blogdata (title, category, content,) VAULE('$title ', '$category', '$content')"; if( !$result = mysql_query($query) ) { echo "<br>Query: $query<br>Produced error: " . mysql_error(); } } else { ?>
  8. Sorry, i don't think I get where this should be added? I have done the following, but still not working: <?php if(isset($_POST['submit'])){ $title = $_POST['title']; $category = $_POST['category']; $content = $_POST['content']; $sql = mysql_query("INSERT INTO blogdata (title, category, content,) VAULE('$title ', '$category', '$content')"); $result = mysql_query($sql); echo "Data has been posted, click <a href='index.php'?here</a> to see it"; }else{ ?>
  9. I have a PHP that when i enter data and click post, I want it to add the info to my data base, but for some reason this is not happening? My PHP code is: <?php mysql_connect ("localhost", "root", ""); mysql_select_db("blog"); ?> <html> <head> <title>Admin - Post new entry</title> </head> <body> <?php if(isset($_POST['submit'])){ $title = $_POST['title']; $category = $_POST['category']; $content = $_POST['content']; $sql = mysql_query("INSERT INTO blogdata (title, category, content,) VAULE('$title ', '$category', '$content')"); echo "Data has been posted, click <a href='index.php'?here</a> to see it"; }else{ ?> <form action='admin.php' method='post'> Title: <input type='text' name='title' /><br /> Category: <input type='text' name='category' /><br /> Content: <textarea name='content'></textarea><br /> <input type='submit' name='submit' value='post!' /> <?php } ?> </form> </body> </html> And my database: id title content category 1 Check 1 Welcome to my site Post 1 2 Check 2 Is it working Post 2 Hope this helps, please can someone tell me why its not updating?
  10. I keep getting an error code when running my php, it states: Parse error: syntax error, unexpected $end in W:\www\blog\login.php on line 33 Line 33 is </html> <?php mysql_connect ("localhost", "root", ""); mysql_select_db("blog"); ?> <html> <head> <title>Login</title> </head> <body> <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $pass = $_POST['password']; $result = mysql_query("SELECT * FROM users WHERE name='$name' AND pass='$pass'"); $num = mysql_num_rows($result); if($num == 0){ echo "Bad login, go <a href='login.php'>back</a>"; }else{ session_start(); $SESSION ['name'] = $name; header("Location: admin.php"); } ?> <form action='login.php' method='post'> Username: <input type='text' name='name' /><br /> Password: <input type='password' name='password' /><br /> <input type='submit' name='sumbit' value='Login!' /> </form> </body> </html> Can any one advise me whats wrong?
  11. I am having more trouble with my code, please see the error below when loading my browser: Here is my blog Fatal error: Function name must be a string in W:\www\blog\index.php on line 14 My code is: <?php mysql_connect ("localhost", "root", "gwalia"); mysql_select_db("blog"); ?> <html> <head> <title>Show My Blog</title> </head> <body> Here is my blog<hr/> <?php $sql = mysql_query("SELECT * FROM blogdata ORDER BY id DESC"); While($row = mysql_fetch_array($sql)){ $title = $row('title'); $content = $row('content'); $category = $row('category'); ?> <table border='1'> <tr><td><?php echo $title; ?></td><td><?php echo $category; ?></td></tr> <tr><td colspan='2'><?php echo $content; ?></td><td></tr> </table> <?php } ?> </body> </html> Line 14 is '$title = $row('title');'. But i do not know what is wrong with my code, help please?
  12. Problem connecting? Parse error: syntax error, unexpected T Postby soc86 » Mon Sep 12, 2011 6:24 am I keep getting the following error: Parse error: syntax error, unexpected T_STRING in W:\www\blog\index.php on line 2 For some reason if you look at my code i believe there is something wrong with the php connecting to my sql database: <?php mysql_connect('localhost','root','root'); mysql_select_db('blog'); ?> <html> <head> <title>Show Me Blog</title> </head> <body> Here is my blog<hr/> <table border='1'> <tr><td>Blog Title</td><td>category</td></tr> <tr><td colspan='2'>content</td><td></tr> </table> </body> </html> I am using uniform server http://www.uniformserver.com/ and i have checked and my username and password is root?
  13. Sorry, but i dont follow? Do i need to add: $headers = 'From:' . $to . '' . "\r\n" .'Reply-To: ' . $to . '' . "\r\n" .'X-Mailer: PHP/' . phpversion();$headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";mail($email, $subject, $message, $headers);() to the HTML or my PHP? and what part of the code/HTML? Many Thanks in advance!!
  14. Contact Form Not Working, Help please Postby soc86 » Thu Sep 08, 2011 1:33 pm Hi, I am a bit of a novice in PHP, but i am having blank emails sent to my email address, is anyone able to tell me where i am going wrong? My codes below: PHP <?php $field_name = $_POST['full_name']; $field_email = $_POST['email']; $field_telephone = $_POST['telephone']; $field_message = $_POST['message']; $mail_to = 'shaun_o_c@yahoo.co.uk'; $subject = 'Contact form'.$field_name; $body_message = 'From: '.$field_name."\n"; $body_message .= 'E-mail: '.$field_email."\n"; $body_message .= 'Message: '.$field_message; $headers = 'From: '.$cf_email."\r\n"; $headers .= 'Reply-To: '.$cf_email."\r\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank You.'); window.location = 'index-4.html'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('Fail ba'); window.location = 'index-4.html'; </script> <?php } ?> HTML <h2>Contact Form</h2> <form id="ContactForm" action="contact.php" enctype="multipart/form-data"> <div> <div class="rows"><input name="full_name" class="input" type="text" value="Name:" onblur="if(this.value=='') this.value='Enter your Name:'" onFocus="if(this.value =='Enter your Name:' ) this.value=''" /></div> <div class="rows"><input class="email" type="text" value="E-mail :" onblur="if(this.value=='') this.value='Enter your E-mail:'" onFocus="if(this.value =='Enter your E-mail:' ) this.value=''" /></div> <div class="rows"><input class="relephone" type="text" value="Telephone (optional):" onblur="if(this.value=='') this.value='Enter your Phone:'" onFocus="if(this.value =='Enter your Phone:' ) this.value=''" /></div> <div class="textarea_box"><textarea name="message" cols="1" rows="1" onBlur="if(this.value=='') this.value='Enter your Message:'" onFocus="if(this.value =='Enter your Message:' ) this.value=''" >Skriv inn din melding:</textarea></div> <a href="#" class="link1" onClick="document.getElementById('ContactForm').reset()">Reset</a> <a href="#" class="link1" onClick="document.getElementById('ContactForm').submit()">Send</a> </div> </form>
×
×
  • 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.