-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
array_walk('fmessage', array_keys($_POST), array_values($_POST)) that part is what is causing the error. the first parameter is supposed to be an array variable, not a string. I'm not sure what you trying to accomplish with this, but thats where the error lies
-
Newbie creating login with sessions.
mikesta707 replied to AStrangerWCandy's topic in PHP Coding Help
meh, storing passwords in a session variable probably isn't the best idea, but it is best to store something unique about the user in a session so you know who is logged in at the time. The user only submits their username once, so you only really have one chance to store something unique about that user so you can access his information on other pages (be they an account page, forums, etc.) You don't necessarily need to store the username, but a unique user_id or unique email address or something unique is usually necessary -
Newbie creating login with sessions.
mikesta707 replied to AStrangerWCandy's topic in PHP Coding Help
for one, associative array keys (basically array keys that are names, and not numbers) have to be surrounded by single quotes. Since you surround the whole variable with single quotes, you should concatenate the sql query string with the values, like so $sql2 = "SELECT userName FROM Users WHERE userName='".$_POST['username']."' AND passWord='".$_POST['password']."'"; also, you are doing two queries for no real reason. you can grap both username and password with one query $sql2 = "SELECT userName, passWord FROM Users WHERE userName='".$_POST['username']."' AND passWord='".$_POST['password']."'"; im not even sure what your doing in this line $users = array('$result1' => '$result2'); but get rid of it. its completely wrong. If you want to check if the user exists on the database, you want to do a mysql_num_rows check, IE if(mysql_num_rows($result1) == 1){ return true;//user successfully logged on } return false;//login unsuccessful im also not really sure what if (! array_key_exists($_POST['username'], $users)) { $errors[] = 'Please enter a valid username and password.'; } is supposed to accomplish either.. that won't really check for anything useful im ny opinion. However, you are on the right track! good luck with the rest of your PHP experience! -
Problem with google maps geo-location code or insert into db
mikesta707 replied to sandy4's topic in PHP Coding Help
check to make sure you sessions variables are correct. should it be $_SESSION['Clever_IP_country'] or any other combination of uppercase, or lowercase letters. also make sure you put session_start() at the beginning of your php page -
you are returning the wrong variable. the variable $grass is nonexistent in the function, until you return it, which instantiates it with a value of null. You have to return the variable $tile. you function should be function tile(){ $tile = "grass"; return $tile; }
-
Nevermind, figured it out. This is awesome! function setCustomFunc(name){ //The line below will add the function that whatever class this function is part of eval("this."+name+"="+name); // the line below will execute the function //eval("this."+name+"()"); }
-
Is there a way to dynamically add a function to an already existing class? What I want to do is create a function that will allow the user to define new functions that are not already in the class. I have the following so far which doesn't produce any errors, but doesn't work even in the slightest function setCustomCriteria(func, name, where){ eval(func); eval("this."+name+"="+name); eval("this."+name+"()"); } and here is where I call it function go(){ alert("Worked!"); } object.setCustomCriteria(go, "go", "nowhere"); I'm sure that is horribly wrong, but that was just a shot in the dark because, frankly, im sort of lost
-
Terminating script on a caught exception
mikesta707 replied to mikesta707's topic in PHP Coding Help
nevermind. I have learned the errors of my ways. Thank you for that link, very helpful! -
javascript and PHP don't play nice with each other most of the time. Make sure that your form is created before you write that statement. try posting your whole code
-
Yep, edit options aren't hard to code in either. Just takes a good grasp of CSS and replacing certain strings with other strings. For example, if you wanted to create a bold button you would replace bold takes [b][/b] with html strong tags <strong></strong> But to be honest, I'm sure there are already build systems that have this stuff, but I personally like reinventing the wheel (which most people advise against) so I would build it myself, but the basic logic is very simple and easy to implement so creating your own system shouldn't take much time or effort
-
yeah you just need to create a new session. No need to destroy any other sessions. Make sure you have session_start() at the beginning of your page though. creating a new session is pretty straight forward, just like $_SESSION['newSess'] = "New Value";
-
instead of if ($count == 0 || $count == 11 || $count == 21 || $count == 31 || $count == 41 || $count == 51 || $count == 61 || $count == 71 || $count == 81 || $count == 91) just do if (($count % 10) == 0) It should work much better. Also, the first has 11 because you check if the count is 11 (which will result in 11 columns), than check in increments of 10
-
Does your server have an SMTP mail server installed. make a page and write phpinfo(); and check to see if SMTP is configured on the server
-
AND I SWING MY MIGHTY BANHAMMA um.. Well what is supposed to happen? and what do you mean by nothing happens? Blank page? table doesn't update? try adding or die(mysql_error()); to the end of all your queries to see if you get an error
-
Ajax stands for Asynchronized JavaScript and XML btw. Its basically just Javascript on steroids though.
-
read your question wrong. nevermind ig got it.
-
BTW there is a hire a coder forum if your willing to pay money, but 5 dollars is a pretty lolzy amount. Given your problem though, it shouldn't be that hard to figure out. the problem is your form's action is set to get, and your variables try to get the data via post. you have two extremely easy options. Either change the following line in your form <form action="angi_contactus.php" method="get" enctype="application/x-www-form-urlencoded" name="interest" id="interest"> to <form action="angi_contactus.php" method="post" enctype="application/x-www-form-urlencoded" name="interest" id="interest"> OR change your php from $name = $_POST['name'] ; $email = $_POST['email'] ; $tel = $_POST['tel'] ; $question = $_POST['question'] ; to $name = $_GET['name'] ; $email = $_GET['email'] ; $tel = $_GET['tel'] ; $question = $_GET['question'] ;
-
well, if you are just beginning I would hold off until you understand the fundamentals of the HTML DOM, and some Ajax functionality (That doesn't mean don't learn JavaScript. JavaScript is awesome. So dam awesome). However, as for your problem, I would suggest using sessions for now. You can always change things at a later date.
-
Terminating script on a caught exception
mikesta707 replied to mikesta707's topic in PHP Coding Help
Hmm interesting. Do exit() and die() show technical information even if you don't tell it to? so for example die(); and die("OH GOD"); would either of those show any information that I am not aware of. I was under the impression that unless I defined a string to output, It would just terminate. If so, where is this information accessible? -
haha nice pun.
-
I've created a few different news systems, and they can be very simple to very complicated. It depends on how simple/complicated you want it to be really. but the basic idea is that you have a page where you post the news to the database, and a different page where you show the latest news on the database.
-
Nope, its defined in the URL itself. So when you go to the page: www.mysite.com/food.php?id=tacobell a get variable with the key 'id' is created. similarly if you went to www.mysite.com/food.php?socks=tacobell a get variable named socks would be created, which could be accessed the way I posted above. You can think of the $_GET global as an array, much like the following $arr = new Array(); $arr['my'] = "array"; $arr['is'] = "awesome"; And when you go to a URL that is like mysite.com/food.php?id=tacobell its as if you wrote the PHP $_GET['id'] = "tacobell"; Make more sense? As you see, since you define the variables in a URL, any user can theoretically create or alter your get variables, so its best not to use them for passing sensitive data to the script, and you should always sanitize get variables before you do anything with them.
-
if you have columns that are integers you don't want to surround variables with single quotes. q = "UPDATE test SET money=money-$train_money, units=units+$train_s WHERE id='$user[id]'"; try that
-
I'm not sure you are supposed to have a semi-colon at the end of SQL queries but I might be wrong...
-
Terminating script on a caught exception
mikesta707 replied to mikesta707's topic in PHP Coding Help
Ahh I see, Thank you. This clears things up quite a bit. Besides the turning away users like the plague, are there any other concerns, security wise most importantly, that I should be aware of? I shall check out those functions you posted posthaste! thank you again