PHP - Registeration Problem
Dear All,
It is my first time to be in your forum, which seems to be gorgeous. I would like to seek your help with my php script where I want to match two passwords together but it is not working. In addition to that, can anyone suggest to me more scripts for security enhancements. I appreciate your help and time. Code: [Select] <?php $username=$_POST["usrename"]; $title=$_POST["title"]; $fname=$_POST["firstname"]; $lname=$_POST["surname"]; $birth[d]=$_POST["day"]; $birth[m]=$_POST["month"]; $birth[y]=$_POST["year"]; $prof=$_POST["prof"]; $password = md5($_POST["pass"]); $pass= md5($_POST["pass_conf"]); $mobno=$_POST['tele1']; $lanno=$_POST['tele2']; $worno=$_POST['tele3']; $e_add[1]=$_POST["email1"]; $e_add[2]=$_POST["email2"]; $address[hn]=$_POST["housen"]; $address[st]=$_POST["street"]; $address[ci]=$_POST["city"]; $address[co]=$_POST["county"]; $address[cy]=$_POST["country"]; $zip=$_POST["post"]; $details=$_POST["details"]; include ("db.php"); if ($title && $fname && $lname && $birth[d] && $birth[m]&& $birth[y]&& $password && $pass) { if ($password==$pass) { $query = "SELECT FirstName FROM users WHERE FirstName = '$fname'"; $result = @mysql_query($query); $num = @mysql_num_rows($result); if ($num==0) { $users = "INSERT INTO users (User_ID, UserName, Title, FirstName, LastName, Password, Birth) VALUES('', '$username', '$title', '$fname', '$lname', '$password', '$birth[d] $birth[m] $birth[y] ')"; $phone = "INSERT INTO phones (Phone_ID, Mobile_NO, Work_NO, Landline_NO) VALUES('', '$mobno', '$worno', '$lanno')"; $address = "INSERT INTO Address (Address_ID, House_NO, Street, City, Region, Country, ZIP_POST, Other_Details) VALUES('', '$address[hn]', '$address[st]', '$address[ci]', '$address[co]', '$address[cy]', '$zip', '$details')"; $email = "INSERT INTO Emails (Email_ID, Email1, Email2) VALUES('', '$e_add[1]', '$e_add[2]')"; $input[1]=mysql_query($users) or die(mysql_error()); $input[2]=mysql_query($phone) or die(mysql_error()); $input[3]=mysql_query($address) or die(mysql_error()); $input[4]=mysql_query($email) or die(mysql_error()); mysql_close(); echo "Account Created "; } else echo "Passwords don't match"; } else die("This username has already been taken"); } else die("Please make sure that all fields are filled in") ?> Similar TutorialsHello, I'm new here but mainly registered because of my PHP registration script I written isn't working... I'm new to PHP by the way. When I press submit on the form, it just goes back to the form again... Below is my script. <?php /* PHP Registeration Script, Allowing new Accounts to be Registered * Written By: freezicx * Year Written: 2011 * Last PHP Update: 2011 */ include("config.php"); $username = strip_tags($_POST['username']); $password = md5(strip_tags($_POST['password'])); $vpassword = md5(strip_tags($_POST['vpassword'])); $email = strip_tags($_POST['email']); $user_ip = $_SERVER['REMOTE_ADDR']; $reg_date = date("d-m-Y"); if(isset($_POST['register'])) { { if (!$username || !$password || !$email || !$vpassword) { echo "You must fill out all fields."; } else { } $dupe1 = mysql_num_rows(mysql_query("select * from users where user='$username'")); if ($dupe1 > 0) { echo "Sorry, that Username is already in use."; } else { } $dupe2 = mysql_num_rows(mysql_query("select * from users where email='$email'")); if ($dupe2 > 0) { echo "Sorry, that Email is in use."; } else { } if ($password != $vpassword) { echo "Your Passwords do not match."; } else { } mysql_query("insert into users (username, email, password, user_ip, reg_date) values('$username','$email','$password','$user_ip','$reg_date')")or die("Error adding account information into database."); echo 'You are registered successfully, you may now <a href="index2.php">login to your account</a>.'; }} ?> <html> <head> <title>LevelZ - Register an Account</title> </head> <body> <form action="register.php" method="post" name="register"> <table> <tr><td>Username:</td><td><input type="text" name="username"></td></tr> <tr><td>Email:</td><td><input type="text" name="email"></td></tr> <tr><td>Password:</td><td><input type="password" name="password"></td></tr> <tr><td>Verify Password:</td><td><input type="password" name="vpassword"></td></tr> <tr><td colspan=2 align=center><input type="submit" id="register" value="Join!"></td></tr> </table> </form> </body> </html> As I'm new to PHP, I can't see the error.... Thanks in advance any way! Guys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.
This is the code:
<table style="width:100%; margin-left:auto; margin-right:auto"> Hi, i use mysql_real_escape_string() function when insert in db, but when echo i use htmlentities($var, ENT_QUOTES, "UTF-8") Now problem is '\ in that text. In db it write text with single quote with \, example That\'s wrong, and when echo it show just the same like in db.. How can i fix this ? Hi, I am trying to write in an existing excel file. But for some reason, I can't open the workbook (but I know I have made similar code work before). Here I am just pasting the code upto the error line $filename="C:\\apache\\htdocs\\GAC2\\dload\\template.xls"; $excel = new COM("excel.application") or die("Unable to instanciate excel"); $excel->Visible = 1; $excel->DisplayAlerts = 1; try{ $wkb = $excel->Workbooks->Open($filename); }catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } //........ Later part of the code This returns the following error Code: [Select] Caught exception: Source: Microsoft Office Excel Description: Unable to get the Open property of the Workbooks class For record, the I have already validated the file location. And I have tried the following line instead without any positive result. Code: [Select] $filename="C:\apache\htdocs\GAC2\dload\template.xls"; Looking for any help please. -Abd Code: [Select] <?php require('config.php'); $sql = "SELECT m.Title as title , f.Reg_URL as reg FROM website_main as m JOIN website_front as f LIMIT 0,01 "; $result = @mysql_query($sql) or die(mysql_error()); echo "<table border='3'>"; echo "<font size='9'><tr> <th><FONT COLOR=red><center>Title</center></font></th> <th><FONT COLOR=red>reg</th> </tr></font>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table $reg = $row['reg']; echo "<tr><td bgcolor=''><center>"; echo $row['title']; echo "</td><td bgcolor=''><center>"; echo '.$reg.'; echo "</td></tr>"; } ?> I got a problem i try to use an attribute for $reg but only appears as .$reg. on website anyone know why? Parts i have problems with are $reg = $row['reg']; and echo '.$reg.';. thank you Elo, I'm creating a very simple image list that is function generated which pulls the source from a table in my database, this is my code Code: [Select] $output = "<ul>"; $img_src = get_all_image_src($sel_event['id']); while($src = mysql_fetch_array($img_src)) { for($i=0;$i <= 9; $i++) { $output .= "<li>"; $output .= "<a"; $output .= " class ='album'"; $output .= " rel='group'"; $output .= " href='/images/gallery/'" . $src['img_src'] . $i; $output .= ".jpg"; $output .= " title='sample 1'"; $output .= ">"; //Image Thumb $output .= "<img"; $output .= " src='/images/gallery/'"; $output .= $src['img_thumb_src']. $i . ".jpg"; $output .= "alt='image01' "; $output .= "title='sample title' />"; $output .= "tae"; $output .= "</a>"; $output .= "</li>"; } } $output .= "</ul>"; return $output; and the img src doesnt seems to add up... my folder structure is Sandbox>image>gallery>2011>Mall>Event>Thumbs where Sandbox is the main directory. i tried echoing the $src['img_src'] and it displays correctly the data to be added (which is 2011/Mall/Event/ plus $i and a .jpg) .. sorry noob here... any thoughts? am i missing a simple detail? i have the following sql running on local but i get an error. the sql: $sql = "SELECT * FROM '".TBL_PARENTS."'" or die(mysql_error()); the config file: define('DB_PREFIX', 'forum_'); define('TBL_PARENTS', DB_PREFIX.'parents'); the 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 ''forum_parents'' at line 1 the echoed sql: SELECT * FROM 'forum_parents' as you can see when it is echoed it looks fine. Any ideas? The server im using is wamp server. i have written a script using touch() function for creating new pages.. but the url's appear are not search engine frendly i want the urls to appear like this everyspace filled with - oder than a space because the space makes the url display as http://localhost/gl/uploads/movies/2010/08/The%20Hangman%202010%20Hindi%20Movie%20Watch%20Online/The%20Hangman%202010%20Hindi%20Movie%20Watch%20Online.php I want it to appear this way http://www.onlinewatchmovies.net/hindi/vroom-2010-hindi-movie-watch-online.html any suggestion how can i do this? im making a website it works fine on firefox but on ie doesnt work correctly. page looks weird i see the error is <? include("index/index_files/front/php/include.php"); ?> anyone can help me its in a <html> tab. You may see a lot of things wrong with the code below, but please bring it to my attention! I'm trying to advance my knowledge on OOP, but I'm trying my best to get the basics down. The below code, after selecting the two characters to fight, the page returns nothing, just blank. I'm pretty sure the error lyes within class_li.php, but I'm not exactly sure. Script is attached. Hi I make 3 querys first Order by DESC, second RAND() and third ASC. Now I want that in the second query can't be the same ids (produgg_users.id) that already taken in the first. And in the third not the ids from first and second. Like I have it now the same users can show up in the RAND() and the ASC like in DESC. Here my Script so far: $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY credits DESC LIMIT 10") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p>Simply click <strong>get 1 point</strong> and you will automatically FOLLOW the USER and earn the credit!</p>"; print "<p><font color=\"#0066FF\">Top Members</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } //Lucky Riders $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY RAND() LIMIT 5") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p><font color=\"#0066FF\">Lucky Riders</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } //Lucky Riders $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY credits ASC LIMIT 5") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p><font color=\"#0066FF\">Last Rides</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } Hows it going guys. I am currently having a problem. I had a program that worked. I migrated the website and now the program is broken. Any time i try to run it, i get this error: Quote Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/thegoo20/public_html/class/wordgame/wordgame.php on line 31 Here is the code at that point: Code: [Select] function changeword(){ $result = mysql_query("Select words from CurrentWords"); $totalwords = array(); while ($row = mysql_fetch_array($result)){ $totalwords[] = $row["words"]; } $_SESSION['word'] = $totalwords[rand(0, count($totalwords)-1)]; $_SESSION['scrambled'] = str_shuffle($_SESSION['word']); } where line 31 is the while statement. Any help would be appreciated. Thanks Helloo ever one i need know In PHP the function giving the current time stamp value is time(). So we can write a line like below to get the current time stamp value. <? echo time(); ?> my Question is how to display any value on specific time( where value is stored in database )... Hi guys, I'm working on a side-project whilst my work at Uni is at a low but I'm extremely rusty on PHP; I've not touched it since around '07. Before I get on to my project, which will lift information from external websites, I'm just trying to acquaint myself with cURL again. Before I get flamed, yes this code is largely lifted from a website, but I pretty much understand it. My aim is to be able to get the title of a website, namely Facebook. Whilst this code is fine on seemingly any other website, it doesn't seem to be able to work for Facebook. I've checked the source code, and I really can't see the problem. Can anyone shed some light for me? Code: [Select] <?php $url = 'http://www.facebook.com/'; $webinfo = get_data($url); $title = get_match('/<title>(.*)<\/title>',$webinfo); $content= '<h2>Title of webpage: </h2><p>'.$name.'</p>'; echo $content; function get_match($regex,$content) { preg_match($regex,$content,$matches); return $matches[1]; } //gets the data from a URL function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } ?> Thanks!!! The problem is whit the var $threadid . It dosent work here(it dosen't display the data from database): $dbh = "SELECT *FROM comments WHERE threadid = '".$threadid."' "; But if I assign a value before the that code the html page show correctly. Code: [Select] include("config.php"); $name = $_POST['name']; $comment = $_POST['comment']; $threadid = $_POST['threadid']; if($name & $comment) { $dbh="INSERT INTO comments (name,comment,threadid) VALUES ('$name','$comment','$threadid') "; mysql_query($dbh); } $dbh = "SELECT *FROM comments WHERE threadid = '".$threadid."' "; $req = mysql_query($dbh); while($row=mysql_fetch_array($req)) { echo "<li>"; echo "<br>"."<b>".$row['name']."</b></br>"."<br>".$row['comment']."</br>"; echo "</li>"; } Code: [Select] $('.submit').click(function(){ location.reload(); var name = $("#name").val(); var comment = $("#comment").val(); var threadid = $("#v").val(); var dat = 'name='+name+'&comment='+comment+'&threadid='+threadid; $.ajax({ type:"post", url:"comment.php", data:dat, success:function(){ console.log("dat"); } }); return false; }); Does any1 know what would cause this problem? Here is the url www.mysite.com/profile.php?id=1447835&state=AL&firstname=TOM&lastname=ANDERSON When I try to echo the id, only 6 numbers appear, the 7th is stripped for some reason <? echo ($_GET["id"]); ?> would print 144783 if I change the $ID to 123456789 it will only echo 123456 Hello everyone Just found this forum and really need some help. I'm trying to create a popup contact form for my product pages. I managed to get a php form from a random site and i cant get the form to pop up. http://www.e-sol.co.uk/printer-scanner-copier.php If someone could help i would be very grateful. I am trying to use the following code snippet to return values from a database with a "," after each value apart form the last one. At the moment for testing I have 2 rows with values 1 and 3 $totalRows_Recordset3 equals 2 (I echoed this to check) $i=1; while($row_Recordset3 = mysql_fetch_assoc($Recordset3)) { if($i < $totalRows_Recordset3) { $str = $str.$row_Recordset3['reading'].","; $i=$i+1; } else { $str = $str.$row_Recordset3['reading']; $i=$i+1; } } I get the number 3 which is the last value in the database, but I can't see why I don't get "1,3" I am sure it is something simple but it just escapes me. Thanks in advance for any help Gordon Okey so i made a table that you put your name,author,and message when you submit it , it echoes a table with the name,author and message written (and it also echoes a delete buttom,so delete this post oif necessary) im new to php and i have been with this problem for a couple of weeks so i guess its time to ask for some help the problem is that i dunnot know how to make my delete buttom work! i tried if statement but it dosent work i also tried ternary operation and dint work :S i read that there is something like $post[ID](and this is supposed to get the ID of the post submmited, and delete it) im not sure, im so confused! help! XD this is the code <?php $tittle=$_POST['tittle']; $author=$_POST['author']; $message=$_POST['message']; if ($_POST['submitnews']){ $currentdate= date("y-m-d"); $currenttime=date("H:i:s",strtotime("-6 hours")); $post=mysql_query("INSERT INTO news VALUES('','$tittle','$author','$message','$currentdate','$currenttime')"); echo"Posted!"; } $select=mysql_query("SELECT * FROM news ORDER BY id DESC"); while ($row= mysql_fetch_assoc($select)) { $id=$row['id']; $tittle=$row['tittle']; $author=$row['author']; $message=$row['message']; $date=$row['date']; $time=$row['time']; if ($_SESSION['admin']) { echo " <table width='488px' id='news_table'> <tr> <td> </td> <td> <center><font size='5'>$tittle</font></center><br> </td> </tr> <tr> <td> </td> <td> $message </td> </tr> <tr> <td> </td> <td> <font size='1'>Posted By:<font color='green'>$author</font> on <font color='gray'>$date</font> at <font color='gray'>$time</font></font> <input name='delete' type='submit' value='delete'> <td> </td> </tr><br><br> </table>"; |