Jump to content

reportingsjr

Members
  • Posts

    1,183
  • Joined

  • Last visited

Posts posted by reportingsjr

  1. I am creating a register out of php/sql and I have this coding:

    $query2 = "INSERT INTO `users` VALUES ('" . $_POST['username'] . "', '" . $password . "', '" . $_POST['admin'] . "')";

    But every time I test it I will get an error like this: Error in query: INSERT INTO `users` VALUES ('t', 'tes', 'no'). Duplicate entry 't' for key 1What should I do about this? It is kind of annoying.. Thanks!

  2. what do you mean no spaces or anything before it? this is in the middle of the page!ohhh, I put it at the begining before <html> and it worked! ty, but now it says:Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/login/index.php:14) in /var/www/html/login/index.php on line 45Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/login/index.php:14) in /var/www/html/login/index.php on line 46.. All I did was put some variables into two cookies =\Ohh, its the same for cookies to, nvm!

  3. Hmm, it still gives me the error, I put it before any of the coding except th <? of course...The coding is:

    		<? 	       	session_start();		if(isset($_POST['name']) || isset($_POST['pwd'])){			if(empty($_POST['name'])){				die ("Please enter a username!");			}			if(empty($_POST['pwd'])){				die ("Please enter a password!");			}					$host = "";			$user = "";			$pass = "";			$db   = "";						$connection = mysql_connect($host, $user, $pass) or die ("Sorry, couldnt connect!");						mysql_select_db($db) or die ("Sorry, couldnt select a database!");						$query = "SELECT * FROM `users` WHERE name = '" . $_POST['name'] . "' AND password = '" . $_POST['pwd'] . "'";						$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());			    			if (mysql_num_rows($result) == 1) {        			$_SESSION['login'] = 1;				echo "succesfully logged in!";				if ($row[2] == "yes"){					$session['admin'];				}				if ($_POST['save'] == 1){					setcookie("username", $_POST['name'], time()+(84600*30));					setcookie("pwd", $_POST['pwd'], time()+(84600*30));				}else{					setcookie("username", NULL, mktime() - 3600);					setcookie("pwd", NULL, mktime() - 3600);									}			}else{			echo "Wrong username and password, please go back and try again.";			}			mysql_free_result($result);			mysql_close($connection);		}																		?>

    Thanks for the comments

  4. I have session start() and I get this error:Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/login/index.php:14) in /var/www/html/login/index.php on line 36Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/login/index.php:14) in /var/www/html/login/index.php on line 36Im not sure why it does this and I have to have it!!! PLease help!

  5. Oh, nevermind. I was wondering this because everytime I do this since the rows are so long it will align in like the middle of the page. I just checked tip.its coding and saw valign="top" and I tried it, that makes it go to the top lol.

  6. I am using a table to organize my website (www.rsbattlehelp.com) but.. I cant figure out how to put the links to the side.. When I tried to put two <td>'s The links got scrunched into a row below the updates section (I want it next to that section). I would like it to kind of look like www.tip.it/runescape link part, Becuase I have that many links. Thanks if you help!

  7. Use a combo of PHP and MySQL, you cant just make one out of no where thats custom!EDIT: I need some exp so ill try to make one.Ok! here it is (I know its not too good but im trying to make it better, will add an admin area and edit options).guestbook.php

    <html><body><?phpif(!isset($_POST['post!']){?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"><center>Post on my guest book</center>Your name:<input type="text" name="name" maxlenth="20"><br><input type="hidden" name="date" value="<?php echo date("n/j/y g:i:s A"); ?>">Your post:<br><textarea name="post" cols="50" rows="6" wrap="virtual">Post here</textarea><br><input type="submit" value="post!"></form><?php    }else{/* if the "submit" variable exists, the form has been submitted - look for and process form data *///put into table GBentries//set database variables, connect to mysqlinclude('config.php');//select databasemysql_select_db($db) or die ("Something is wrong!"); //make query to get rows$query = "INSERT INTO `GBentries` VALUES (" . $_POST['name'] . ", " . $_POST['date'] . ", " . $_POST['post'] . ")";//execute query$result = mysql_query($query) or die();//free result set memorymysql_free_result($result);//close connectionmysql_close($connection); }?><?php//set database variables, connect to mysqlinclude('config.php');//select databasemysql_select_db($db) or die ("Something is wrong!"); //make query to get rows$query = "SELECT * FROM `GBentries`";//execute query$result = mysql_query($query) or die();//see if there are any rowsif (mysql_num_rows($result) > 0) {   //there are rows, print them   echo "<table cellpading="5" border="2">";   while($row = mysql_fetch_row($result)) {	echo "<tr>";	echo "<td>Name:" . $row[0] . "</td>";	echo "<td>Date posted:" . $row[1] . "</td>";	echo "<td>Post:" . $row[2] . "</td>";	echo "</tr>";   }   echo "</table>";}else {   //no post yet   //put a table that says no post yet   echo "<table cellpading="5" border="2">";   echo "<tr>";   echo "<td>Sorry, No post in this guestbook yet!</td>";   echo "</tr>";   echo "</table>";}//free result set memorymysql_free_result($result);//close connectionmysql_close($connection); ?></body></html>

    You may need to edit some things (like make a config.php) and other smal bugs and feel free to use this!Also post things that you think would make it better! Thanks!-reportingsjr-

  8. Can you have a value for a checkbox? Anyways, on the action page you should put:

    <?$deletebox = $_POST['delbox'];if($delete = !true) { require("url/php/db.inc.php");$sql->Delete("DELETE FROM members WHERE delbox=1");header("Location: url/confirm.html")?>

    Plus the rest of the databse connection junk.. I think its right, if not ill edit it.

  9. You want to write a map using binary? thats going to ######.. I dont know binary code lol. Hmm, maybe you could do a function so that it adds your four variables together? I dont know though..

  10. Huh? I dont get what you want.. Do you mean like, you want it to check if the person is allowed to login(so they cant just type in the webpage and get to that page) so you need to be authenticated? If so use the PHP function sessions , you will need to read up on this more (check out google).

  11. I know there is code for this but here is the question:How would I put a file into a folder in your website server? I would like to be able to upload images into a folder called /images but dont know the coding. How would I do this?ex: upload picture /tut into folder /images on the server. I would like to know the coding for this please!Thanks for reading this!-reportingsjr

  12. You can text veiw it in any browser to make sure its working.Just follow these steps:1. make document and save2. open browser3. in top corner select File4. Select open file5. find the folder your web page is in and click on it6. click open!! (yay)

  13. Put it in a code block like this:Main.php

    <form method="post" action="login.php"><input name="id" type="text" id="id" size="8" maxlength="8" style="font-size:12px"><input name="pw" type="password" id="pw" style="font-size:12px" value="" size="8"><a href="#" onClick="popwin=window.open('login.php','popwin','scrollbars, width=850,height=650');"><input type="image" src="images/submit.gif" name="submit" value="submit" onClick="()"><input type="submit" value="submit">

    login.php

    <?php$id = "$_POST['id']";$pw = "$_POST['pw']";?>

    use the global command $_POST[''] or $_GET[''] for forums ;-]Also, I edited main.php you had extra things and were missing things. This should work.

×
×
  • Create New...