Jump to content

Hypersource

Members
  • Posts

    19
  • Joined

  • Last visited

Hypersource's Achievements

Member

Member (2/5)

0

Reputation

  1. So I have a basic login script wich checks if the users name was already in the database and if not, puts the data in the database. The problem is that its not checking if the user is already in the database? I have the code in there aswell though? <?php include 'template.php'; // includes the basic connect thing $username = $_GET['username']; if($_GET['postback'] != '1') { echo' <h2>Signup!</h2> <form action=signup.php> <br> <input name="username" placeholder=Username><br> <input name="password" placeholder=Password><br> <input name="email" placeholder=Email type=email><br> <input type="hidden" name="postback" value ="1"> <input type="submit" value ="Sign up!"> </form> '; } else { echo "<br>Signing up...<br>"; $sql="SELECT * FROM `users`"; echo $sql; $result = mysqli_query($con,$sql) or die("ERROR"); $i = 0; echo $i; while($row = mysqli_fetch_array($result)) { if($row['username'] == $username) { $i = 1; echo "That username is in use! Please pick another one."; } } if ($i != 1) { $error = 0; if (strlen($_GET['password']) < 6) { echo "Your password has to be at least 6 characters long!"; $error = 1; } if (strlen($_GET['username']) < 3) { $error = 1; echo "Your username has to be at least 3 characters long!"; } if ($error == 1){ echo' <h2>Signup!</h2> <form action=signup.php> <br> <input name=username placeholder=Username><br> <input name=password placeholder=Password><br> <input name=email placeholder=Email type=email><br> <input type="hidden" name="postback" value ="1"> <input type="submit" value ="Sign up!"> </form> '; } else if($i==0 and $error == 0){ $sql = "INSERT INTO `users`(username,password,email) VALUES('".$_GET['username']."','".$_GET['password']."','".$_GET['email']."')"; print $sql; //mysqli_query($con,$sql); } } else { echo "<br>That username is already taken.<br>"; } } ?> <?php include 'templatend.php'; // closes divs etc form the template file. ?>
  2. ITs a problem with my host. But I worked around it. Thanks guys : )
  3. @mentalist no matter WHAT data I submit it says connection reset.. I even tried a bare-bones forum. (just a submit button nothing else not even php code) [e] it works completly O.K for GET though?!?!
  4. Read title. Code: <?php //error_reporting(-1); //this will show all errors //ini_set('memory_limit', '256M'); //ini_set('max_execution_time', 3000); include 'c.php'; // connects to database $id = $_GET['id']; // get forum id $sid = $id; // ... $text = $_POST['chatext']; // chat text $name2 = $_POST['participant']; // chat username $sname2 = $name2; // .. $ip = $_SERVER['REMOTE_ADDR']; // get users ip for logging $result = ''; //if this is a postback, send data to server. if($_POST['postback'] == 'TRUE') { //everything needs to be sanitized before going into a SQL query $sql = "INSERT INTO posts (ip,text,name,forumid) VALUES ($ip,$text,$sname2,$sid)"; mysqli_query($con,$sql) or die(mysql_error()); $result = 'chat submitted'; // easy error message showing } ?> <center> <b color='red'><?php echo $result; ?></b> <h1>Chat Box</h1> <form method='POST' action='chatbox.php?id=<?php echo $id; ?>'> <input name="participant" placeholder='Your Nickname' value="<?php echo $name2; ?>"><br><br> <textarea name="chatext" placeholder='Chat Here' rows='4' cols='30'></textarea><br><br> <input type='hidden' name='postback' value='TRUE'> <input type='submit' value ='Submit'> </form> </center> c.php: <?php $host = "*"; $database = "*"; $duser = "*"; $dpassword = "*"; $con=mysqli_connect($host,$duser,$dpassword,$database); // Check connection if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?> Thanks!
  5. Here is my complete code: <center> <h2>SecretSearcher</h2> </center> <?php include 'c.php'; echo "Showing results for '"; echo $_POST['keyword']; echo "':"; $sql = "SELECT * FROM searchterms WHERE title = "%$_POST['keyword']%"; $res = mysqli_query($con,$sql); while($row = mysqli_fetch_array($res)) { echo $row['title'] echo $row['description']; echo "<br>"; } ?> <center> <br> Thankyou for searching! </center> [e] I put my code in the syntzx higlighter thing here and It showed me my extra ". Thanks so much phpfreaks!
  6. Thanks @jazzman1 ; Your second answer worked like a charm.
  7. Im working on an image slideshow, but glob() is not working. Here is my code: PHP Version: 5.3 <?php $dir = "http://www.harvester.tk/560/img/*.*"; foreach (glob("$dir") as $filename) { echo $filename; ?>
  8. Heres the error: Parse error: syntax error, unexpected T_WHILE in ****/*/*.php on line 17 The code: <?PHP include 'connect.php'; $tik=$_SESSION['user_name']; $amount= $_POST['amount']; if($amount) { $user= MYSQL_QUERY("SELECT * FROM users WHERE user_name='$tik'")or die(mysql_error); WHILE($row=MYSQL_FETCH_ARRAY($user)) { $club=$row['club']; $cash=$row['cash']; } $c= MYSQL_QUERY("SELECT * FROM club WHERE name='$club' ")or die(mysql_error); WHILE($row=MYSQL_FETCH_ARRAY($c))//Problem Line { $till=$row['till']; $owner=$row['$owner']; } $till=$till+$amount; $cash=$cash-$amount; if($amount > 0 AND $cash > 0) { $epic=mysql_query("UPDATE club SET till='$till' WHERE name='$club'") or die(mysql_error()); $epic=mysql_query("UPDATE users SET cash='$cash' WHERE user_name='$tik'") or die(mysql_error()); header( 'Location: club.php' ); } } } ?> I have know idea whats wrong with the loop.
  9. UPDATE users SET club='$ID', write='0', editmem='0', till='0' WHERE user_name='$tik', I get 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 'write='0', editmem='0', till='0' WHERE user_name='Tester'' at line 1 help?
  10. $tokei=mysql_query("SELECT * from club WHERE name='F.O.R.C.E'")or die(mysql_error()); WHILE ($row=MYSQL_FETCH_ARRAY($tokei)) $mem=$row['member']; I get an unpexpected variable error here help?
  11. Whoops new this was obvious! its the wrong table i need to do the pets table sorry for wasti ng your time
  12. Whats wrong with this i know its obvious : ( $cash=mysql_query("UPDATE potions SET color='$color',pet='$pet' WHERE owner='$tik' and name=' $name ' ") or die(mysql_error()); i get Unknown column 'name' in 'where clause'
×
×
  • 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.