
phpmania1
Members-
Posts
25 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
phpmania1's Achievements

Newbie (1/5)
0
Reputation
-
If anyone could test the security of my login system and or database, and perhaps any coding f-ups.. thanks.
-
SQL> CREATE TABLE your_field ( id int not null primary key, value varchar(20) ); SQL> INSERT INTO const_skills(id, value) VALUES (1, "PHP"); SQL> INSERT INTO your_field(id, value) VALUES (2, "MySQL"); SQL> INSERT INTO your_field(id, value) VALUES (3, "Zope"); SQL> INSERT INTO your_field(id, value) VALUES (4, "Perl"); SQL> INSERT INTO your_field(id, value) VALUES (5, "Javascript"); SQL> INSERT INTO your_field(id, value) VALUES (6, "JSP"); SQL> CREATE TABLE lookup_field ( id int not null auto_increment primary key, uid int, skill_id int ); <?php /* insert code to connect to your database here */ /* get the checkbox labels */ $skills = get_checkbox_labels("const_skills"); /* create the html code for a formatted set of checkboxes */ $html_skills = make_checkbox_html($skills, 3, 400, "skills[]"); ?> <html> <body> <br> <form name="skills" method="POST" action="insertskills.php"> Check off your web development skills: <? echo "$html_skills"; ?> <br> <input type="submit" value="Submit"> </form> </body> </html> <?php function get_checkbox_labels($table_name) { /* make an array */ $arr = array(); /* construct the query */ $query = "SELECT * FROM $table_name"; /* execute the query */ $qid = mysql_query($query); /* each row in the result set will be packaged as an object and put in an array */ while($row= mysql_fetch_object($qid)) { array_push($arr, $row); } return $arr; } /* Prints a nicely formatted table of checkbox choices. $arr is an array of objects that contain the choices $num is the number of elements wide we display in the table $width is the value of the width parameter to the table tag $name is the name of the checkbox array $checked is an array of element names that should be checked */ function make_checkbox_html($arr, $num, $width, $name, $checked) { /* create string to hold out html */ $str = ""; /* make it */ $str .= "<table width=\"$width\" border=\"0\">\n"; $str .= "<tr>\n"; /* determine if we will have to close add a closing tr tag at the end of our table */ if (count($arr) % $num != 0) { $closingTR = true; } $i = 1; if (isset($checked)) { /* if we passed in an array of the checkboxes we want to be displayed as checked */ foreach ($arr as $ele) { $str .= "<td><input type=\"checkbox\" name=\"$name\" value=\"$ele->id\""; foreach ($checked as $entry) { if ($entry == $ele->value) { $str .= "checked"; continue; } } $str .= ">"; $str .= "$ele->value"; if ($i % $num == 0) { $str .= "</tr>\n<tr>"; } else { $str .= "</td>\n"; } $i++; } } else { /* we just want to print the checkboxes. none will have checks */ foreach ($arr as $ele) { $str .= "<td><input type=\"checkbox\" name=\"$name\" value=\"$ele->id\">"; $str .= "$ele->value"; if ($i % $num == 0) { $str .= "</tr>\n<tr>"; } else { $str .= "</td>\n"; } $i++; } } /* tack on a closing tr tag if necessary */ if ($closingTR == true) { $str .= "</tr></table>\n"; } else { $str .= "</table>\n"; } return $str; } ?> <?php /* the function we call to insert. the $skills argument is the skills array that is sent to the script when the user hits the submit button */ function insert_field($uid, $skills) { /* first, we'll delete any entries this user already has in the table */ purge_lookup("lookup_field", $uid); /* now create the sql insert query */ $query = create_checkbox_query($skills, "lookup_field", $uid); /* execute the query */ mysql_query($query); } /* helper function for insert_field(). removes all rows in $table with $uid */ function purge_lookup($table, $uid) { $q = "DELETE FROM $table, WHERE uid = '$uid'"; mysql_query($q); } /* helper function for insert_field(). generates the sctual SQL query */ function create_checkbox_query($arr, $table, $uid) { $q = "INSERT INTO $table (uid, field_id) VALUES"; foreach ($arr as $check) { $q .= " ( $uid , $check )" . ","; } /* remove the last comma and return */ return substr($q, 0, -1); } ?> <?php /* builds a query to search for the field checked off in the $skills array */ function field_search($skills) { if (!empty($skills)) { $query = "SELECT DISTINCT user.username FROM user, const_field, lookup_field WHERE lookup_field.uid = user.id AND lookup_field.field_id = const_field.id "; $query .= " AND ("; foreach ($skills as $check) { $query .= " const_field.id = $check OR"; } /* remove the final OR */ $query = substr($query, 0, -2); $query .= ")"; $count = count($skills); $query .= " GROUP BY user.username HAVING count(user.username) >= $count"; $query .= ";"; return $query; } } ?> Theres a base. Change "field" and tweak it as needed.
-
You don't want the text further than the box? Do you want a bigger text box, or the box to expand as text is inserted?
-
Ok, DUH it is not my footer image it is the website content... still... help? lol.
-
diyrealestate.leadhoster.com/open_realty/index.php My footer won't stay where it is supposed to be.. I have not changed anything and it was where it was supposed to be a second ago... help?
-
I'm well aware, thanks fo rthe pointer. The free host is merely for the process of getting the site ready to publish on a purchased domain. My host is very fair and reliable so I do not mind a banner well I am configuring my page.
-
Awesome thanks, I just finished a logo... although I don't think it looks very good. I'm having alot of trouble with the header/banner. I think I might use a logo with a slogan? footer text was annoying me so I made it small for the time being lol.
-
Alright what do you think now? http://diyrealestate.leadhoster.com/open_realty Only lazuli template, & the banner is part of the free hoster for testing purposes.
-
i took the banner off, im trying new ones. this is what i mean, #mrbanner { position:absolute; top:1px; bottom:1px; } header_right****** is not in my code, and index.html does not call for it there is no * header_right so do i add it into mr banner? #mrbanner { position:relative; position:absolute; top:1px; bottom:1px; } Or would i go to my index.html and call <div id mrbanner>?
-
and header_right? should that not be part of mrbanner since there is nothing in my html that refers to banner_right?
-
now im confused?
-
heh. didn't know you go into negatives Thanks, almost solved... just have to reload until i don't get hte banner!
-
alright but, #mrbanner { position:relative; top:1px; left:180px; } check the site again.. it won't go any higher?
-
i thought it wad too bright earlier? ahah. i'm using gimp, but apparently not properly. a tutorial would be muchly appreciated. i realize it is your opinion, i prefer brutal honesty. I didn't mean to come off offended in the previous posts. I will try the lavender. makes sense, a darker background draws attention to the background, and takes the attention off of the actual page. a lighter, passive background will give them nothing to look at.!
-
So. Banner, Position: absolute. Free hoster. Google ad comes and goes. When google ad comes, banner good. when google ad goes, banner in the middle of the freakin page. Any pointers? diyrealestate.leadhoster.com/open_realty/index.php