Search found 205 matches

by ExtremeGaming
Sun Dec 09, 2012 9:57 pm
Forum: Tutorials
Topic: Session variable in string
Replies: 7
Views: 1298

Re: Quick help plz

My bad I should've expected that :oops:

This should be the error.
[syntax=php]echo "Welcome $_SESSION['username']";[/syntax]

Change it to
[syntax=php]echo "Welcome ".$_SESSION['username']." ";[/syntax]
by ExtremeGaming
Sun Dec 09, 2012 9:30 pm
Forum: Tutorials
Topic: Session variable in string
Replies: 7
Views: 1298

Re: Quick help plz

Single quoted variables don't get parsed in php [syntax=php]<script type="text/javascript"> <!--Invocation code--> var infobar=new informationbar() infobar.setContent('<?php if ($_SESSION['username']){ echo "Welcome $_SESSION['username']"; }else{ echo 'Welcome to GameCrayz! Pleas...
by ExtremeGaming
Sun Dec 09, 2012 8:55 pm
Forum: Tutorials
Topic: Session variable in string
Replies: 7
Views: 1298

Re: Quick help plz

[syntax=php]<?php if(isset($_SESSION['username'])) { ?> <script type="text/javascript"> window.alert("Welcome <?php echo $_SESSION['username']; ?>!"); </script> <?php } else { ?> <script type="text/javascript"> window.alert("Welcome to GameCrayz! Please log in. Nee...
by ExtremeGaming
Sun Dec 09, 2012 7:42 pm
Forum: Tutorials
Topic: Login error
Replies: 10
Views: 1743

Re: Login error

Sorry I was thinking of md5. I edited the post; sha1 is 40 characters in length.

You will also need to register a new user.
by ExtremeGaming
Sun Dec 09, 2012 7:29 pm
Forum: Tutorials
Topic: Login error
Replies: 10
Views: 1743

Re: Login error

Your error is that sha1() creates a 40-byte password (40 characters in length) and you have a limit of 30 characters in the password field, thus cutting off 10 from the string. Until you fix that and register a new user, you will never be able to log in.
by ExtremeGaming
Sun Dec 09, 2012 4:34 pm
Forum: Tutorials
Topic: Login error
Replies: 10
Views: 1743

Re: Login error

If there are no errors that means everything should be working correctly. Remove that part because it's useless now.

What is your database structure? The type and max length of characters in your password column.

Example: Varchar (50)
by ExtremeGaming
Sun Dec 09, 2012 2:45 am
Forum: PHP
Topic: Restrict functions file?
Replies: 2
Views: 707

Restrict functions file?

More of a question then a problem... Is there any reason that I might want to put a sessions check in a functions file to check if only an admin uses it? For clarification I will give an example. I'm creating an admin backend for a friend's website and I am checking if say: add_user.php and mod_user...
by ExtremeGaming
Sun Dec 09, 2012 1:53 am
Forum: Tutorials
Topic: Login error
Replies: 10
Views: 1743

Re: Login error

Add this to the very first line within your php on login.php, then run your form again.

[syntax=php]error_reporting(E_ALL);
ini_set('display_errors', '1');[/syntax]
by ExtremeGaming
Sat Dec 08, 2012 9:59 pm
Forum: Tutorials
Topic: Login error
Replies: 10
Views: 1743

Re: Login error

The only thing I see that could be happening is your query is failing or you are entering the wrong username and password...try changing your query in the valid_credentials functions to match the one below. [syntax=php] function valid_credentials($user, $pass){ $user = mysql_real_escape_string(htmle...
by ExtremeGaming
Sat Dec 08, 2012 8:17 pm
Forum: PHP
Topic: Register and Login (User Account System)
Replies: 4
Views: 3367

Re: Register and Login (User Account System)

In which function is it not updating? I also notice that you aren't displaying any of the $errors[]. Perhaps there are some and you can't see them because of that.
by ExtremeGaming
Sat Dec 08, 2012 5:58 pm
Forum: PHP
Topic: Register and Login (User Account System)
Replies: 4
Views: 3367

Re: Register and Login (User Account System)

mysql_error() and msql_error() are totally different. Did you try mysql_error in your add_user function like this: [syntax=php] <?php //Adds a user to the database. function add_user($user, $pass){ $user = mysql_real_escape_string(htmlentities($user)); $pass = sha1($pass); mysql_query("INSERT I...
by ExtremeGaming
Fri Dec 07, 2012 10:18 pm
Forum: PHP
Topic: "Edit" function on Blog posts
Replies: 8
Views: 1328

Re: "Edit" function on Blog posts

Yes, you're going to have to change your form action to [syntax=php]<form action="?pid=<?php echo $_GET['pid']; ?>"[/syntax] Then your if(): [syntax=php]if (isset($_POST['title'], $_POST['body'], $_GET['pid'])){ edit_post($_POST['title'], $_POST['body'], $_GET['pid']); die(); }[/syntax] Th...
by ExtremeGaming
Fri Dec 07, 2012 9:06 pm
Forum: PHP
Topic: "Edit" function on Blog posts
Replies: 8
Views: 1328

Re: "Edit" function on Blog posts

Remove the $pid = $_POST['id'] as it will always return blank because your form contains no field of id. Remove it from the if statement as well. I believe what you are looking for is $post['id'] for the function variable instead of $_POST['id']; However, to get this to work your form action will ne...
by ExtremeGaming
Fri Dec 07, 2012 3:43 pm
Forum: PHP
Topic: "Edit" function on Blog posts
Replies: 8
Views: 1328

Re: "Edit" function on Blog posts

Add an extra parameter in your edit_post function to store the $_POST['id'] I don't think once inside the function you can post data like that

$_POST['id'] will return blank and thus there will cause no error
by ExtremeGaming
Thu Dec 06, 2012 1:25 pm
Forum: PHP
Topic: cannot edit profile
Replies: 89
Views: 11302

Re: cannot edit profile

You are supposed to use $user_info = fetch_user_info($_SESSION['uid']); I'm not sure if that whitespace you added matters. It shouldn't. Looking back at what Temor said, I believe I see what they were talking about. [syntax=php] if (empty($errors)){ $grad = htmlentities($_POST['grad']); $drzava = ht...
by ExtremeGaming
Thu Dec 06, 2012 3:20 am
Forum: PHP
Topic: cannot edit profile
Replies: 89
Views: 11302

Re: cannot edit profile

You only need the = $row['uid'] in the login process. Change those (user.inc.php and edit_profile.php) back to just $_SESSION['uid']
by ExtremeGaming
Thu Dec 06, 2012 12:01 am
Forum: PHP
Topic: cannot edit profile
Replies: 89
Views: 11302

Re: cannot edit profile

Whatever column in the database you are using to store the user's uid (I believe it is just called uid) set the $_SESSION['uid'] with it. [syntax=php] if(mysql_num_rows($checklogin) == 1) { $row = mysql_fetch_array($checklogin); $_SESSION['Username'] = $username; $_SESSION['LoggedIn'] = 1; echo &quo...
by ExtremeGaming
Wed Dec 05, 2012 11:53 pm
Forum: PHP
Topic: cannot edit profile
Replies: 89
Views: 11302

Re: cannot edit profile

You can set many session variables. No need to edit any.

If you need help, post the file that you process your login.
by ExtremeGaming
Wed Dec 05, 2012 11:49 pm
Forum: PHP
Topic: cannot edit profile
Replies: 89
Views: 11302

Re: cannot edit profile

That does not mean you are setting $_SESSION['uid'] Wherever you are processing the user login, if you do not see yourself setting $_SESSION['uid'] You need to.
by ExtremeGaming
Wed Dec 05, 2012 11:45 pm
Forum: PHP
Topic: cannot edit profile
Replies: 89
Views: 11302

Re: cannot edit profile

All files already call each other. You can not call a file with functions twice because a function can not be redeclared, hence the error you are getting. You must remove that include you added to remove the error. Are you setting $_SESSION['uid'] when you log in your users? If not, you need to. I r...
by ExtremeGaming
Wed Dec 05, 2012 10:29 pm
Forum: PHP
Topic: cannot edit profile
Replies: 89
Views: 11302

Re: cannot edit profile

The fetch_user_info function is gathering data from the user using their uid. Not their username, as your previously posted. Replace $_SESSION['Username'] with whatever their session uid is stored as. I'm not sure why you are setting their $_SESSION['uid'] to 1 in init.inc.php either as each user sh...