Jump to content

ringworld

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ringworld's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Reply to: unkwntech Yah Im starting to see what you mean. Here is a snippet of code that reads a users data and also updates a users data. This is a lot of crap already and, I just added 2 more tables and tons more rows to my data base that all need to be accounted for in the same way. Do you have any suggestions to make this any smaller or cleaner. $result = mysql_query("SELECT * FROM users WHERE username = '$userhandle'"); if (!$result) { echo 'Unable to get data ' . mysql_error(); exit; } $row = mysql_fetch_row($result); //echo $row[0]; //userID //echo $row[1]; //username //echo $row[2]; //password //echo $row[3]; //email //echo $row[4]; //active //echo $row[5]; //name //echo $row[6]; //tagline //echo $row[7]; //content1 //echo $row[8]; //content2 //echo $row[9]; //content3 //echo $row[10]; //content4 //echo $row[11]; //content5 //echo $row[12]; //text_color_title //echo $row[13]; //text_color_main //echo $row[14]; //content_border_color //echo $row[15]; //content_border_type //echo $row[16]; //content_border_size //echo $row[17]; //content_background_color_title //echo $row[18]; //content_background_color_main //echo $row[19]; //background_color_body //echo $row[20]; //background_image_body } if(isset($_POST['update'])) { $name = $_POST['name']; $tagline = $_POST['tagline']; $email = $_POST['email']; $content1 = $_POST['content1']; $content2 = $_POST['content2']; $content3 = $_POST['content3']; $content4 = $_POST['content4']; $content5 = $_POST['content5']; $text_color_title = $_POST['text_color_title']; $text_color_main = $_POST['text_color_main']; $content_border_color = $_POST['content_border_color']; $content_border_type = $_POST['content_border_type']; $content_border_size = $_POST['content_border_size']; $content_background_color_title = $_POST['content_background_color_title']; $content_background_color_main = $_POST['content_background_color_main']; $background_color_body = $_POST['background_color_body']; $background_image_body = $_POST['background_image_body']; $query = "UPDATE users SET email='$email', name='$name', tagline='$tagline', content1='$content1', content2='$content2', content3='$content3', content4='$content4', content5='$content5',text_color_title='$text_color_title', text_color_main='$text_color_main', content_border_color='$content_border_color', content_border_type='$content_border_type', content_border_size='$content_border_size', content_background_color_title='$content_background_color_title', content_background_color_main='$content_background_color_main', background_color_body='$background_color_body', background_image_body='$background_image_body' WHERE username = '$userhandle'"; mysql_query($query) or die(mysql_error()); echo "Your profile has been updated.";
  2. Why is it not better to use a class? I have tons of reading and writing going on in my project, its it only needed in large applications? Also I don't know much about PDO, isn't it just meant to make your program more portable? Also what does Mysqli do that mysql can't, Is Mysqli becoming a standard?
  3. I have been looking for a mysql class written in php to make my project more OO. I have found tons of scripts but they are all overly complicated, don't do everything I want, or are just confusing. I cant help it but I am kind of a noob.......lol. Does anyone know of a class or tutorial that will show me how to make a class that can do the following: connect/read/write/delete/handle multiple tables. i am really looking for a short an concise script because I really want to be able to understand it. Thanks for your help.
  4. This is what I have so far. //make user file $thetext=" <?php //Call Database & Connect require_once('headers/database.php'); connect(); //will this work? $user_name ?>"; $user_file_name = $_POST['user_name']; $filename="profiles/$user_file_name/$user_file_name.php"; $tempvar = fopen($filename,"w"); fwrite($tempvar, $thetext); fclose($tempvar); What I am trying to do is pass a variable, $user_name, into this file that is being generated. Lets say $user_name is ringworld, I want the written file to contain is "$ringworld" not $user_name. Can this be done? If so how? I am confused so I don't expect you guys to understand what I mean, If you need to know more just ask! Thanks!
  5. I was thinking the same thing but the js way may bee more complicated, I actually did this the javascript way once and it was glitchy. If I come across the code I will post it here.
  6. Okay, here is the final code with a submit button and some things to make page look better. <html> <head> <style> body{ padding: 0px; margin: 0px; } </style> </head> <body> <form action="iframe.php" method="post"> Enter a web address:<input type="text" name="url"> <input type="submit" value="Go /> <br /> <?php $url = $_POST['url']; echo "<iframe width='100%' height='500px' frameborder='0' src='http://"; echo $url; echo "'></iframe>"; ?> </body> </html>
  7. you have to hit enter, it is possible to put a button in though
  8. Yes that is it. I actually have everything you said there besides a way to make a script that actually post their data on a page, thats where I need help.
  9. This code is called iframe.php <html> <body> <form action="iframe.php" method="post"> Enter a web address:<input type="text" name="url"> <?php $url = $_POST['url']; echo "<iframe src='http://"; echo $url; echo "'></iframe>"; ?> </body> </html> That works, I just made it and tested it myself, I am proud of myself lol , I have been wanting to do the same for a long time. You may notice that when you run the page the iframe show up with page cannot be found. That is because I added http:// because when you run the script locally if you put www.google.com in it would look for it on your site. So you have to put http://www.google.com in.
  10. I know its a long read but I think every detail is important! Very useful and interesting problem. Hi am new to the forum, but I have used this site in the past. The reason I made an account is because a site that makes me pay to get help and answers just doesn't get the job done. There is one user (many people under same name) who answers every question that is posted but I get the feeling that they did not even read my question. So thats why I am here now. Enough of that now onto the question, Currently I am working on a user account and profile system, meaning that users can register and create profiles that can be viewed by the public. There are with out a doubt thousands of tutorials on the internet that focus on user authentication, but not once have I been able to find one that dealt with a profile system (some say they do but the titles are misleading), I did however, recently find a set of scripts that gets close. The system I have now, allows users to register, filling in a variety of fields. What makes it special is that they can later edit those details through a page called profile.php. What is missing, though is a method of just anyone viewing their profile. And that is exactly what I want to do. What I think need to be done is that on register, a folder is created (e.x. http://www.mysite.com/ringworld) with the persons user name as the folder name. This doubles as an easy way for someone to view a profile. Inside that folder there should be a file called something like profile.php that holds the code to display the data for that specific user that is being held in the mySQL database. This part is a little confusing because I am unsure how the php program would know how to display the data for a user just by knowing their user name. Would the user name be attached to other data in the mysql table? should the register script generate a separate table for each user that holds their information? I have had it pointed out to me that I may need to change the profile.php script and that would be difficult to do if I had a lot of members. I could use includes and have the only actual code in the file be $username = 'ringworld';. So basically the user variable would be in their php file and their would be a master-profile.php included into all of the user profiles. As you can see I have a lot of things to figure out. If anyone here can help me, or point to some helpful tutorials or code it would be much appreciated. Thanks a billion!!! Se ya around the forum. Oh I almost forgot, I am running on Apache, using Xampp localy on my PC. Code for register.php as I have it now: <?php //Call Database & Connect require_once('headers/database.php'); connect(); //We need functions require_once('headers/functions.php'); //Get Admin Values $get_cd = mysql_query("SELECT * FROM `memb_config`"); while($each = mysql_fetch_assoc($get_cd)){$$each['config_name'] = $each['config_value'];} //Get user count $user_count = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM `memb_userlist`")); //Is registartion enabled? if($CF_E_REG == 2){ echo 'Registration is currently disabled.';return;} //Did the limit exceed allowed registrations? if($CF_USER_LIMIT > 0 && $CF_USER_LIMIT <= $user_count[0]){ echo 'User registration limit of '.$user_count[0].' was exceeded.';return;} //Get custom fields $array_custom = array(); $get_fields = mysql_query("SELECT * FROM `memb_customfds`"); while($each = mysql_fetch_assoc($get_fields)){ array_push($array_custom,$each); } //If verifying registration if($_GET['ver'] != NULL){ $user_status = mysql_escape_string($_GET['ver']); $get_inf = mysql_fetch_assoc(mysql_query("SELECT `user_email`,`user_password` FROM `memb_userlist` WHERE `user_status`='$user_status'")); $update = mysql_query("UPDATE `memb_userlist` SET `user_status`='1' WHERE `user_status`='$user_status' LIMIT 1"); if($update){ $message = 'Your email has been confirmed. Thanks.'; editfule($CF_FDACCESS,'Add',"\n",$get_inf['user_email'].':'.crypt($get_inf['user_password']),''); }else{$message = 'Unable to confirm email. Internal Error.';} } //If registering if($_POST['Submit'] == 'Register'){ //Check standard fields if($_POST['user_name'] == NULL){$message = 'Please enter user name.';} if($message == NULL && is_valid_email($_POST['user_email']) == false){$message = 'Please enter a valid email.';} if($message == NULL && $_POST['user_password2'] == NULL){$message = 'Please enter password twice.';} if($message == NULL && $_POST['user_password2'] != $_POST['user_password']){$message = 'Passwords do not match.';} //Check Email existence if($message == NULL){ $_POST['user_email'] = mysql_escape_string($_POST['user_email']); $get_email = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM `memb_userlist` WHERE `user_email`='$_POST[user_email]'")); if($get_email[0] > 0){ $message = 'This email is already registered. Please enter a different email, or use forgot password link.';} } //Check Custom Fields if($message == NULL){ foreach($array_custom as $field){ if($_POST['fieldxy_'.$field['field_id']] == NULL){ $message .= 'Please enter the '.$field['field_name'].' field<br/>'; } } } //Check Cpatcha if($message == NULL){ $realanswer = trim(encode_decode(hex2bin($_POST['registration_id']),$CF_ENCDEC)); if($CF_CAPTHCA == 'IMAGE'){ if($_POST['answer'] != $realanswer){ $message = 'Please enter the correct verification code.'; } } else { if($realanswer != '*' AND $realanswer != $_POST['answer']){ $message = 'Please answer the question correctly.'; } } } //Everything OK, procceed if($message == NULL){ $remove_array = array('Submit','answer','registration_id','user_password2'); $array_fields = array(); $array_values = array(); //Compose needed info $random_string = generate_session(50); if($CF_E_VER == 2){ $_POST['user_status'] = '1'; }else{ $_POST['user_status'] = $random_string; $ad_text = '<br/>Before using this account, you will need to confirm the email we just send you.'; } $_POST['register_date'] = date("Y-m-d G:i:s"); $_POST['last_access'] = date("Y-m-d G:i:s"); $_POST['last_ip'] = get_ip(); //Compose Query foreach($_POST as $is => $what){ $what = mysql_escape_string($what); if(eregi('fieldxy_',$is)){ $is = trim($is); if($is){ $field_id = str_replace('fieldxy_','',$is); $_POST['custom_fields'] .= "[$field_id]{+|%|+}[$what]\n"; } } else { if(!in_array($is,$remove_array)){ array_push($array_fields,"`$is`"); array_push($array_values,"'$what'"); } } } array_push($array_fields,'`custom_fields`'); array_push($array_values,"'$_POST[custom_fields]'"); //Make Query $insert = mysql_query("INSERT INTO `memb_userlist` (".implode(',',$array_fields).") VALUES (".implode(',',$array_values).")") or die(mysql_error()); if($insert){ $sent = welcome_user($_POST,$random_string,$CF_SITENAME,$CF_SITEEMAIL); if($_POST['user_status'] == 1){ editfule($CF_FDACCESS,'Add',"\n",$_POST['user_email'].':'.crypt($_POST['user_password']),''); } if($send){ $message = 'Your account has been added.'.$ad_text; } else { $message = 'Account added, but we were unable to delivery confirmation email. Please contact us ASAP.'; } $_POST = NULL; }else{ $message = 'Unable to register your account. Internal Error.'; } } } //Disconnect Database disconnect_data(); ?> <form name="register" id="register" method="post" action="<?=$_SERVER['PHP_SELF'];?>" style="display:inline;"> <table width="100%" border="1" cellspacing="0" cellpadding="5"> <tr> <td colspan="2"><div align="center"><font color="#999999" size="4">Register for an account</font></div></td> </tr> <?php if($message != NULL){ ?> <tr bgcolor="#FFDDDD"> <td colspan="2"><strong><font color="#FF0000"><?=$message;?></font></strong></td> </tr> <?php } ?> <tr> <td width="50%">Choose you user name: </td> <td width="50%"><input name="user_name" type="text" id="user_name" value="<?=$_POST['user_name'];?>"> [Required] </td> </tr> <tr> <td width="50%">Your email: </td> <td width="50%"><input name="user_email" type="text" id="user_email" value="<?=$_POST['user_email'];?>"> [Required<?php if($CF_E_VER == 1){echo ' AND requires confirmation';}?>] </td> </tr> <tr> <td width="50%">Keep yourself updated on new stuff, care to join our mailing list? </td> <td width="50%"><?php if($_POST['user_in_list'] == '1' || $_POST['user_in_list'] == NULL){$sel = ' checked';}else{$sel=NULL;}?> <input name="user_in_list" type="radio" value="1"<?=$sel;?>> Yes <?php if($_POST['user_in_list'] == '2'){$sel = ' checked';}else{$sel=NULL;}?> <input name="user_in_list" type="radio" value="2"<?=$sel;?>> No</td> </tr> <tr> <td>Please select a password: </td> <td width="50%"><input name="user_password" type="password" id="user_password" value=""> [Required] </td> </tr> <tr> <td>Re-enter the password: </td> <td width="50%"><input name="user_password2" type="password" id="user_password2"> [Required] </td> </tr> <?php foreach($array_custom as $field){ ?> <tr> <td><?=$field['field_name'];?></td> <td width="50%"><input name="fieldxy_<?=$field['field_id'];?>" type="text" id="fieldxy_<?=$field['field_id'];?>" value="<?=$_POST['fieldxy_'.$field[field_id]];?>"> <?php if($field['is_required'] == 1){ echo '[Required]';} ?> </td> </tr> <?php } if($CF_CAPTHCA == 'IMAGE'){?> <tr> <td>Enter Verification Code: </td> <td><table border="0" cellspacing="0" cellpadding="5"> <tr> <td class="acont"><div align="center"> <?php $referenceid = md5(mktime()*rand()); //Generate the random string $chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k", "K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v", "V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9"); $length = $CF_LENGH; $textstr = ""; for ($i=0; $i<$length; $i++) { $textstr .= $chars[rand(0, count($chars)-1)]; } $new_string = encode_decode($textstr,$CF_ENCDEC); $image_link = bin2hex($new_string); ?> <img src="captcha.php?code=<?=$image_link;?>"> <input name="registration_id" type="hidden" id="registration_id" value="<?=$image_link;?>"> </div></td> </tr> <tr> <td class="acont"><div align="center"> <input name="answer" type="text" id="answer"> </div></td> </tr> </table></td> </tr> <?php } else { $f = fopen($CF_QUESTIONFILE,'r'); while($t = fread($f,102465)){ $content .= $t; } fclose($f); $content = trim(preg_replace('/\/\*.*\*\//ism', '', $content)); $temp = explode("\n",$content); $random = rand(0,count($temp)-1); $rand = $temp[$random]; list($question,$registration_id) = explode('\n\\',$rand); $registration_id = bin2hex(encode_decode($registration_id,$CF_ENCDEC)); ?> <tr> <td>Answer this: <strong><?=$question;?></strong> </td> <td><input name="answer" type="text" id="answer" value="<?=$_POST['answer'];?>"> <input name="registration_id" type="hidden" id="registration_id" value="<?=$registration_id;?>"></td> </tr> <?php } ?> <tr> <td colspan="2"><div align="center"> <input type="submit" name="Submit" id="Submit" value="Register"> </div></td> </tr> <tr> <td colspan="2"><div align="center">[<a href="login.php">Login</a> - <a href="forgotpass.php">Forgot Password</a>] </div></td> </tr> </table> </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.