wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
isset doesn't check whether the form field is filled in. It checks whether the variable iexits, ie it checks whether $_GET['title'] exists. If you want to check the contents of the variable you'll want to use empty but empty will still return true if there is a space in the form field. If you want to check that they have fillled in the form field correctly, such as they have entered at least 4 or more characters into the form field you'll want do this [code]if (isset($_GET['title']) && (strlen($_GET['title']) >= 4)) { $title = $_GET['title']; echo "the title is $title"; }[/code]
-
Textfield/area - keep recent added text in view
wildteen88 replied to redbullmarky's topic in Javascript Help
I dont know how to do it but I do know that you'll need to use a function called scrollTo which you can use to make the texbox scroll to the end when a word is inserted. The syntax is like this: [code]srollTo(x position, y position)[/code] -
You'll want to use Buyocats query and the code will be like this: [code]//connect to database $sql = "SELECT user_id FROM user_table WHERE username = '$username' LIMIT 1"; $result = mysql_query($sql); if(myql_num_rows($result) == 1) { echo "Username in use"; } else { //continue to register user }[/code] Also you might want to set the username field to be UNIQUE too.
-
no need for a third party script use [a href=\"http://uk2.php.net/manual/en/function.explode.php\" target=\"_blank\"]explode[/a]. Look at example 1 secound example.
-
I don't know if this is a mod/admin feature when in full edit mode but there is an option where you can choose to show the editted by message, look for this setting when in full edit mode. [code]Add the 'Edit by' line in this post?[/code] I think this is an mod/admin only feature.
-
Umm, thats a good point there poirot I always forget about unix timestamp will only work with dates prior to Jan 1 1970! But unix timestamp is okay for doings things such as logging when someone posts a message or logs in etc but not with DoB's
-
My only advice with heredoc is [b]NEVER[/b] indent the closing indentifer as PHP will through an error, so EOD or what ever idenfier you may use must not be indented, it must be at the very beginning of the line on its own. Heredoc is good for echoing large amounts of text rather than using seperate echo statements.
-
When using sessions you do have [b]session_start();[/b] as the first line of code in every page that uses sessions dont you? Otherwise it seems that your sessions are not being handled correctly!
-
It is best to store the date and time as a unix timestamp in one field. Then when you get the timestamp out of the database you can use the date function to format the time stamp: [code]date("d-m-y", $row['timestamp']);[/code] Also you can easily compare dates too with timestamps.
-
Okay this code here is completly wrong: [code]echo($logs_data['userid,username,hostname,time,type,message']);[/code] it should be this: [code]echo $logs_date['userid'] . "<br />\n" . $logs_date['username'] . "<br />\n"; echo $logs_date['hostname'] . "<br />\n" . $logs_date['time'] . "<br />\n"; echo $logs_date['type'] . "<br />\n" . $logs_date['message'];[/code]
-
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]2. About the control structure and everything, advice/feedback/information, anything anyone wants to offer for clarification purposes.[/quote] I prefer to have my brakets in place that way I know where my code blocks are, but if its small code blocks then I may not include them but most of the time I will put them in. This basically down to personal preference just go with what you like best. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]3. Any other functions that can be used to replace mysql_real_escape_string, maybe what it really does, I looked it up, but it's confusing, I don't understand why it's needed, and I see alot of other very, very experience php programmers not using this, but this advice was given to me by someone I really trust, and have a dear friendship with, but I always like double checking, getting other peoples opinions, and everything else.[/quote] mysql_real_escap_string is only used when inserting data into a mysql database to make the data safe. It basically has the following functions addslashes and htmlspecialchars/htmlentities in one function.
-
Thats because if you use 0 on its own PHP recognises this as FALSE. When you place quotes around 0 and 1 PHP treats as numerical values rather than treating them as true or false. So basically PHP was asking itself whether $legaue_password_check is equal to [b]false[/b] [code]if ($league_password_check == 0){ all other code goes here }[/code] But your new code now tells PHP to check whether $legaue_password_check is equal to [b]0[/b] rather than false.
-
What do you mean by restart that person session? You can change a persons session anywhere in your script such as you can do this: [code]<?php session_start(); $_SESSION['lvl'] = "Something"; //some other code here $_SESSION['lvl'] = "hello world"; ?>[/code] When you run that code first PHP will set the lvl session to 'Something' then further down PHP will rewrite the lvl session to 'hello world'. You dont need to destorythee session and then reset the session if you are chaning something in the session! You only do that when you are using cookies.
-
Yes, $_SERVER['HTTP_REFERER'] This variables stores the location the user came from. This is set by the web browser so not all browsers will send this variable.
-
Was you echoing out $level or $_SESSION['level']. If you was echoing out $level that will not update as holds the old value of level session. If you echo'd out $_SESSION['level'] that should echo out your new level that you set with the form. Looks you have a bug in your script somewhere if the new session data isn't comming through.
-
Looking at your code. it looks like you can do with a complete recode really. Like so: [code]<?php include 'db_con.php'; $numb = ( ( isset($_GET['numb']) && is_int($_GET['numb']) ) ? $_GET['numb'] : die("hacking attempt")); $sql_n = "SELECT * FROM news WHERE id = '$num' LIMIT 1"; $result_n = mysql_query($sql_n); if(mysql_num_rows($result_n) >= '1') { $news = mysql_fetch_array($result_n); $title = $news["title"]; $date = $news["date"]; $new = $news["new"]; $shortnew = $news["shortnew"]; echo "<span id=virs>" . $title . "</span><br />"; echo "<span id=dat>" . $date . "</span><br />"; echo $new; echo "<br /><br /><br /><br /><br />"; $sql_c = "SELECT * FROM comments WHERE newsid='$numb' ORDER BY id DESC"; $result_c = mysql_query($sql_c); if(mysql_num_rows($result_c) < '1') { echo "no comments in database"; } else { while($comments = mysql_fetch_array($sql_c)) { $author = $comments["author"]; // coment author $coment = $comments["coment"]; // coment $comentdate = $comments["comentdate"]; // date of the coment echo "<span id=au>" . $author . "</span><br />"; echo "<span id=dat>" . $comentdate . "</span><br />"; echo $coment . "<br /><br />"; } } } //not sure what this was so I left it if(empty($_GET['numb']) OR $num <> 1) { $sql = mysql_query("select * from zinjas order by id desc"); while($row = mysql_fetch_array($sql)) { echo "<span id=virs><a href=zinjas.php?numb=" . $row["id"] . ">" . $row["title"] . "</a></span><br />"; echo "<span id=dat>" . $row["date"] . "</span><br />"; echo $row["shortnew"]; echo "<br /><br />"; echo "<div class=komentari><a href=zinjas.php>Coments</a></div>"; } } ?>[/code]
-
Session data is updated automatically so you dont need to create a new session for the data come available! Where did you get that from?
-
making sure an email contains all the fileds I want
wildteen88 replied to barça's topic in PHP Coding Help
[!--quoteo(post=382590:date=Jun 11 2006, 07:30 PM:name=Richard181)--][div class=\'quotetop\']QUOTE(Richard181 @ Jun 11 2006, 07:30 PM) [snapback]382590[/snapback][/div][div class=\'quotemain\'][!--quotec--] maybe he wants those widthin the email in that case you change them to variables $namefield=$_POST['namefield']; them put all of them how ever you want the form to show.. [/quote] Which is what I have done. [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] -
What do you mean by refresh? Do want the browser to refesh the page? If so why? To refresh the page in javascript you can do this: [code]header("Refresh: 0; url=" . $_SERVER['PHP_SELF']);[/code] provided that you dont have any output to the browser before you use that code.
-
making sure an email contains all the fileds I want
wildteen88 replied to barça's topic in PHP Coding Help
Change your code to this: [code]$mailbody = $_POST['title'] . "\n"; $mailbody .= $_POST['namefield'] . "\n"; $mailbody .= $_POST['concerning'] . "\n"; $mailbody .= $_POST['comments'];[/code] Is that what you want? If not could explain in more detail what you are trying to do. -
To pass the level as session do this: [code]<?php session_start(); //put code here that gets the users level $_SESSION['level'] = $level; ?>[/code] Then when you want to retrieve the session make sure you have session_start on the page that checks the user level, see my post above.
-
When sending emails with PHP sometimes email clients treat these as spam emails and so they dont arrive in your inbox instead they'll be located in your junk/spam folder. Also I see you are not validating user input, you should validate user input as a malicous hacker/spammer could pertentially spam your client.
-
How is $level being populated? Are you setting the variable like so: $level = $_SESSION['level'] I think you'll be best of with a switch rather than if/elseif statement like so: [code]<?php session_start(); //make sure you have this line whenever you are dealing with sessions $level = $_SESSION['level']; switch($level) { case 5: echo "level 5"; break; case 4: echo "level 4"; break; case 3: echo "level 3"; break; case 2: echo "level 2"; break; case 1: echo "level 1"; break; case 0: echo "level 0"; break; defualt: die("Unknown level script has been killed! level is:" . $level) break; }[/code] When you use that depending on the value of $level it should echo out the level, if $level is not set to 0,1,2,3,4 or 5 it'll kill the script and echo the value pf $level
-
What part of that code is the comments bit? Or is that the actual comment code? If it is why is there 3 or 4 queies to get the comments out of the database.
-
justin15 you should include some from of form validation rather than getting the user to check whether the information is correct for example, check whether the user has field in the Name and Comment Fields and if they have provided an email address make sure it is a valid address. If they didnt fill in the name or comment field you should display a message and if their email address isn't valid show a message.