Jump to content

blueman378

Members
  • Posts

    888
  • Joined

  • Last visited

    Never

Everything posted by blueman378

  1. Hi guys, im just curious as to how much information you can get from a users (involuntarily) with a combination of php and javascript, eg i know you can get: a users OS a users IP a users Browser a users Locale but what else can you grab?
  2. This is more a problem with the original SMF theme isnt it? Ill send them a support ticket requesting them to look at this topic.
  3. although for small projects it becomes a bit much...
  4. and so what does the error say: unknown column test. ah so that means that there is no column called test in the table you have connected to. remember that column names are CaSe SeNsItIvE
  5. knoew it was something to do with remote andway dont forget to mark the topic as solved.
  6. oh sorry mate, um here you go </html> <head> <title>myform</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Name: <br /> <input type="text" name="name" size="30" value="<?php if(!empty($_SESSION['name'])) { echo $_SESSION['name']; } ?>" /><br /> <?php if(!empty($_SESSION['nameerror'])){ echo "The name field cannot be left empty!"; } ?> Email: <br /> <input type="text" name="email" size="30" value="<?php if(!empty($_SESSION['email'])) { echo $_SESSION['email']; } ?>" /><br /> <?php if(!empty($_SESSION['emailerror'])){ echo "The email field cannot be left empty!"; } ?> <input type="submit" value="Submit" /> </form> </body> </html> <?php $_SESSION['emailerror'] = ''; $_SESSION['nameerror'] = ''; $_SESSION['email'] = ''; $_SESSION['name'] = ''; if($_POST['submit']) { if(empty($_POST['email']) && empty($_POST['name'])) { $_SESSION['emailerror'] = '1'; $_SESSION['nameerror'] = '1'; header("location: $_SERVER[php_SELF]"); } elseif(empty($_POST['email'])) { $_SESSION['emailerror'] = '1'; $_SESSION['name'] = $_POST['name']; header("location: $_SERVER[php_SELF]"); } elseif(empty($_POST['name'])) { $_SESSION['nameerror'] = '1'; $_SESSION['email'] = $_POST['email']; header("location: $_SERVER[php_SELF]"); } $databasename='week3'; // Name of the database $tablename='email'; // Name of the table $mysqladd='localhost'; // Address to the MySQL Server - Usually localhost or an IP address $mysqluser='root'; // Your MySQL UserName $mysqlpass=''; // Your MySQL Password @$name = addslashes($_POST['name']); @$email = addslashes($_POST['email']); ///CONNECT TO MYSQL working $link=mysql_connect($mysqladd,$mysqluser,$mysqlpass) or die('Database Error: ' . mysql_error()); //CONNECT TO DATABASE working mysql_select_db($databasename, $link) or die('Could not connect to table: ' . mysql_error()); //Get data from Text, Post data to database working $strQuery = "INSERT INTO `email`(`name`,`email`)VALUES (\"$name\",\"$email\")" ; $result = mysql_query($strQuery); if (!$result) { die('Invalid query: ' . mysql_error()); } // print data table from database $result = mysql_query("SELECT * FROM email"); while($row = mysql_fetch_array($result)) { echo $row['name']; echo $row['email']; echo "<hr />"; } // this doesn't return all the data in the table. It is only returning what I just entered. } ?> youll nitoce i changed test.php to the php server variable PHP_SELF, this basically says use this file as the action
  7. im proborably wrong but $type = $_GET['type']; if (isset($type)) isnt he setting $type? even if it is set as null? shouldnt it be if (!empty($type)) for what he is doing? ...in comes crayon to make me look dumb
  8. this doesnt make sense. I am not getting a message saying "Unknown column 'test' in 'where clause'" did oyu mean i am now?
  9. also i might point out i learnt php without a single book, i simply thought of a project i wanted to do 9in my case a forum) broke it down into each part i will need to learn and started googling. matt
  10. Sure, the basics of what i changed was see how everything after the $_SESSION['emailerror'] = ''; $_SESSION['nameerror'] = ''; $_SESSION['email'] = ''; $_SESSION['name'] = ''; is encased in the if(isset($_POST['submit'])) { } youll notice your submit button is called submit so basically its saying only run the code if $_POST['submit'] is set. which the only way this can get set is via pressing the submit button. as for the error handling thats jsut an extra i added in. basically you'll see that i have put <?php if(!empty($_SESSION['nameerror'])){ echo "The name field cannot be left empty!"; } ?> with the name changed for email). that basically says if the error session is NOT(!) empty then display the message. These only get set if they are empty. this is so that your users dont get confused as to why it is not submitting there details. not youll notice ive added value="<?php if(!empty($_SESSION['name'])) { echo $_SESSION['name']; } ?>" (with the name changed for email again) this is simply saying if the value is set the echo it there. this means that if your user puts in the email but not the name then they will get the message saying they cant leave name blank, and email will already be filled out for them. this part here $_SESSION['emailerror'] = ''; $_SESSION['nameerror'] = ''; $_SESSION['email'] = ''; $_SESSION['name'] = ''; is after the form. because the values get shown in the form we cant clear it above the form. and we have to clear it above the if statements because the value in the if statements will not get set. any other questions just ask. btw good on you for asking to get it explained, alot of people simply go ive got working code i dont need to know how it works and thats wrong, because then we end up with those same poeple asking the same questions again. Matt
  11. if your connecting with dreamweaver its considered a remote connection, (unless its your localhost) try checking with your hosting company to see if remote connections are enabled.
  12. cheers crayon, only reason i didnt point that out is because it seems his question was is it ok to pass a variable on the same page?
  13. try replacing line 32 with if(isset($_POST['submit']))
  14. na mate your on the right track. although use if (empty($_GET['type'])) { bla bla bla instead of if ($_GET['type'] == '') {
  15. i jsut showed you up there <?php //some php code here ?> anyway this is proborably what you want i also added in some error handling for you. </html> <head> <title>myform</title> </head> <body> <form method="post" action="test.php"> Name: <br /> <input type="text" name="name" size="30" value="<?php if(!empty($_SESSION['name'])) { echo $_SESSION['name']; } ?>" /><br /> <?php if(!empty($_SESSION['nameerror'])){ echo "The name field cannot be left empty!"; } ?> Email: <br /> <input type="text" name="email" size="30" value="<?php if(!empty($_SESSION['email'])) { echo $_SESSION['email']; } ?>" /><br /> <?php if(!empty($_SESSION['emailerror'])){ echo "The email field cannot be left empty!"; } ?> <input type="submit" value="Submit" /> </form> </body> </html> <?php $_SESSION['emailerror'] = ''; $_SESSION['nameerror'] = ''; $_SESSION['email'] = ''; $_SESSION['name'] = ''; if($_POST['submit']) { if(empty($_POST['email']) && empty($_POST['name'])) { $_SESSION['emailerror'] = '1'; $_SESSION['nameerror'] = '1'; header("location: $_SERVER[php_SELF]"); } elseif(empty($_POST['email'])) { $_SESSION['emailerror'] = '1'; $_SESSION['name'] = $_POST['name']; header("location: $_SERVER[php_SELF]"); } elseif(empty($_POST['name'])) { $_SESSION['nameerror'] = '1'; $_SESSION['email'] = $_POST['email']; header("location: $_SERVER[php_SELF]"); } $databasename='week3'; // Name of the database $tablename='email'; // Name of the table $mysqladd='localhost'; // Address to the MySQL Server - Usually localhost or an IP address $mysqluser='root'; // Your MySQL UserName $mysqlpass=''; // Your MySQL Password @$name = addslashes($_POST['name']); @$email = addslashes($_POST['email']); ///CONNECT TO MYSQL working $link=mysql_connect($mysqladd,$mysqluser,$mysqlpass) or die('Database Error: ' . mysql_error()); //CONNECT TO DATABASE working mysql_select_db($databasename, $link) or die('Could not connect to table: ' . mysql_error()); //Get data from Text, Post data to database working $strQuery = "INSERT INTO `email`(`name`,`email`)VALUES (\"$name\",\"$email\")" ; $result = mysql_query($strQuery); if (!$result) { die('Invalid query: ' . mysql_error()); } // print data table from database $result = mysql_query("SELECT * FROM email"); while($row = mysql_fetch_array($result)) { echo $row['name']; echo $row['email']; echo "<hr />"; } // this doesn't return all the data in the table. It is only returning what I just entered. } ?>
  16. can you please do us a favor and use tags? </html> <head> <title>myform</title> </head> <body> <form method="post" action="test.php"> Name: <br /> <input type="text" name="name" size="30" /><br /> Email: <br /> <input type="text" name="email" size="30" /><br /> <input type="submit" value="Submit" /> </form> </body> </html> <?php $databasename='week3'; // Name of the database $tablename='email'; // Name of the table $mysqladd='localhost'; // Address to the MySQL Server - Usually localhost or an IP address $mysqluser='root'; // Your MySQL UserName $mysqlpass=''; // Your MySQL Password @$name = addslashes($_POST['name']); @$email = addslashes($_POST['email']); ///CONNECT TO MYSQL working $link=mysql_connect($mysqladd,$mysqluser,$mysqlpass) or die('Database Error: ' . mysql_error()); //CONNECT TO DATABASE working mysql_select_db($databasename, $link) or die('Could not connect to table: ' . mysql_error()); //Get data from Text, Post data to database working $strQuery = "INSERT INTO `email`(`name`,`email`)VALUES (\"$name\",\"$email\")" ; $result = mysql_query($strQuery); if (!$result) { die('Invalid query: ' . mysql_error()); } // print data table from database $result = mysql_query("SELECT * FROM email"); if($row = mysql_fetch_array($result)) { echo $row['name']; echo $row['email']; echo "<br />"; } // this doesn't return all the data in the table. It is only returning what I just entered. ?>
  17. case 'searchlastname': == case $_POST['searchlastname']; altohugh i would suggest you change your form action to get and change that to $_GET['searchlastname']; otherwise a user cant save that search.
  18. sounds like your host is fluctuating a bit. either that or some values that are dependant are getting set wrong. try a different host and see if that fixes your problem.
  19. try this mysql_select_db($database_users, $users) or die(mysql_error()); $query_users = "SELECT * FROM users"; $users = mysql_query($query_users, $users) or die(mysql_error()); $row_users = mysql_fetch_assoc($users); $totalRows_users = mysql_num_rows($users) or die(mysql_error());
  20. its giving you the unix timestamp now convert that to a date with http://nz.php.net/manual/en/function.date.php
  21. hi mate, try adding or die(mysql_error()); after your querys so basically mysql_select_db($database_users, $users) or die(mysql_error()); $LoginRS__query=sprintf("SELECT `user`, password FROM users WHERE `user`=%s AND password=%s", GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text"));
  22. I gave you the answer already. Why are you arguing with people when you should be reading up on amfphp and how to use it. because you gave him a name, that means he still has to do research, thats not code
×
×
  • 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.