[PHP] About "wrapping" a forum into your own design.

2006-03-28 Thread twistednetadmin
I am making a page with css for styling and php for browsing and dynamic
content.
I use a simple switch statement to get the main content of each page into
the same  tag like this:




However. I am not that competent in PHP to make my own forum, so I use a
premade forum. Invision Power Board actually.

What I want to do is to get all the links I press in the forum (after
loading "forum/index.php" into the div-tag with id=main) to show up in the
same area. Not sure if this is a php question actually, but...

What happens now is that when I press the link "Forum" in my main navigation
on my site, the index.php of course loads into the div-tag with id=main. BUT
when I press a topic or something within this page (index.php), it opens up
in a new page. I know why, but I wonder if there is a way to get the rest of
the links in the forum to stay within my div-tag other than tracking down
all the variables and such in the forumscripts and alter them? (That's a
hell of alot java and php to work through)

Any help is appreciated.


[PHP] Right syntax for max value??

2005-06-14 Thread twistednetadmin
I am making a table at my homepage that automatically collects the
latest news from mysql db.
 I have got it to work at my own server at home, but not at
www.torewestre.com (my remote site)

Local settings:(WinXP Pro) Apache 2.0.54, PHP 5.0.4 and MySQL 4.1.11

Remote settings:(Unix) Apache 1.3.27, PHP 4.3.4 and MySQL 3.23.54

This is the query that works on localhost:


$getnewstitle = "SELECT newstitle FROM `news` WHERE news_id = ( SELECT
max( news_id ) FROM news ) ";

What it does:

collects the newstitle from the field where PRIMARY key(news_id) is
the highest auto_increment number.

This works just as excpected on localhost but not on remote.

Does anybody know the right syntax?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Userlogin system seems to override the if statement....

2005-10-12 Thread twistednetadmin
I'm new to this. So I used a tutorial to write this. But it shows "Login ok.
Welcome" at once when the page loads. Here is the tutorial:
http://www.ss32.x10hosting.com/ss32/files/PHP-logins.pdf



There was an error processing your login.






Login as:




Password:










Login ok. Welcome ";
}
?>

I don't get any further. I must be missing something, but what??

Please help.

-Tore W-


[PHP] Login is not working. Please help....

2005-10-13 Thread twistednetadmin
When I fill in the form with user and password, it goes to the
loginerror.php anyway.
Is this because I use switch with only one case(I'm going to make more
later), and if it is. What should I use instead?
This is my first php-script. I have tested this on both php4 and php5.
Please help.

(login.php)
 0) // password is correct
{
$_SESSION['auth']="yes";
$logname=$_POST['user'];
$_SESSION['logname'] = $logname;
header("Location: page1.php");
}
else // password is not correct
{
unset($action);
header("Location: loginerror.php");
}
}
elseif ($num == 0) // Wrong name. Name not in db
{
unset($action);
header("Location: loginerror.php");
}

}

?>

(form.php)








Login as:






Password:















[PHP] Still struggeling with my first script...

2005-10-14 Thread twistednetadmin
Here are all the scripts original. It still won't work. I can't see what's
wrong with it???
It's from the tutorial PHP5 and Mysql for dummies. I have shorted it
down though, since I am the only one who will register the User with a
password. What I did was removing the Switch at the beginning of the
loginscript(Guildlogin1.php) and change it with an if statement instead.
Don't think that is the problem though. I use php5 with MySql 4.1.7 on my
testingserver(Apache 2.0)

--
Register.php(this works):
--



HOoSRegisterpage for new membersHOoS





















New user:




Password:

















-
Guildlogin1.php
-
 0) //password is correct
{
$_SESSION['auth']="yes";
$logname=$_POST['guilduser_name'];
$_SESSION['logname'] = $logname;
header("Location: HolyOrder1.php");
exit();
}
else //password is not correct
{
unset($guildaction);
$message="Login not correct";
header("Location: Guildloginerror.php");
}
}
elseif ($num == 0) // Wrong name. Name not in db
{
unset($guildaction);
$message="Login failed";
header("Location: Guildloginerror.php");
}

}

?>

form:

http://www.w3.org/TR/html4/loose.dtd
">


HOoSloginpage for membersHOoS




























Login as:




Password:




















Re: [PHP] Still struggeling with my first script...

2005-10-14 Thread twistednetadmin
All: Sorry. I forgot to write what's wrongstupid me...
Mike:1) I'm not sure how to indent the code...
2) I'm using Dreamweaver, but not to write the code for me. I'm not that
lazy :). And that's not the way for me to learn.
It's just rather annoying that all the tutorials I have tried seems to fail.
How can I learn when I'm apparently given the wrong information.
I am searching php.net  for the right code, but it can be
rather overwhelming at some points

Chris: No, it did not work before I made these changes.



The way it should work:
---
Register.php
-
Sends the information from the form(guilduser_name and guilduser_pass) to
the DB, encrypting the password with md5 encryption.
This works as intended. No need for any security since am the only one with
access to this.

Code for Register.php:




HOoSRegisterpage for new membersHOoS





















New user:




Password:


















---
Guildlogin.php
---
This should create a session variable for the authentication, but it fails
at some point. I have checked the sessiondata on my testserver, and that
shows blank. So it's clear for me that I don't get the information saved in
the variable $_SESSION.
I don't get any sql errors, so I don't think that is the problem. But then
againit is my first script, and I could offcourse be wrong.
I'm not sure where I should put the echo $sql; to check the query.Since the
Guildlogin.php sends me directly to the error page at the end of execution.
The script sends me to the loginerror.php even if the username and the
password is correct.
The point here is that this happens every time I press the button "login" in
the form, regardless of the input in the form.

Code for Guildlogin.php:
--
 0) //password is correct
{
$_SESSION['auth']="yes";
$logname=$_POST['guilduser_name'];
$_SESSION['logname'] = $logname;
header("Location: HolyOrder1.php");
exit();
}
else //password is not correct
{
unset($guildaction);
$message="Login not correct";
header("Location: Guildloginerror.php");
}
}
elseif ($num == 0) // Wrong name. Name not in db
{
unset($guildaction);
$message="Login failed";
header("Location: Guildloginerror.php");
}

}

?>
---
The form:
---
I don't feel it's nessesary to explain this...
---
Code for loginform:
---

http://www.w3.org/TR/html4/loose.dtd";>


HOoSloginpage for membersHOoS




























Login as:




Password:


















---
End
---
I hope this was a better explanation than the last one...hehe...
I guess I was busy pulling out my hair...

-TW-


Re: [PHP] Still struggeling with my first script...

2005-10-14 Thread twistednetadmin
Did one change in the script guildregister.php:

Changed the md5 part in the INSERT query to:

$sql_reg = sprintf("INSERT INTO guildlogin (guilduser_name, guilduser_pass)
VALUES ('%s', password('%s'))",
$_POST['guilduser_name'],
$_POST['guilduser_pass']);
$reg = mysql_query($sql_reg) or die(mysql_error());

On 10/15/05, twistednetadmin <[EMAIL PROTECTED]> wrote:
>
> All: Sorry. I forgot to write what's wrongstupid me...
> Mike:1) I'm not sure how to indent the code...
> 2) I'm using Dreamweaver, but not to write the code for me. I'm not that
> lazy :). And that's not the way for me to learn.
> It's just rather annoying that all the tutorials I have tried seems to
> fail. How can I learn when I'm apparently given the wrong information.
> I am searching php.net <http://php.net> for the right code, but it can be
> rather overwhelming at some points
>
> Chris: No, it did not work before I made these changes.
>
>
>
> The way it should work:
> ---
> Guildregister.php
> -
> Sends the information from the form(guilduser_name and guilduser_pass) to
> the DB, encrypting the password with md5 encryption.
> This works as intended. No need for any security since am the only one
> with access to this.
> 
> Code for Register.php:
> 
>
> 
> 
> HOoSRegisterpage for new membersHOoS
> 
> 
> 
>
> 
>  include ("connections/HOoStest.php");
>
>
>
> if (isset($_POST["MM_insert"]) && $_POST["MM_insert"] == "reg") {
> $sql_reg = sprintf("INSERT INTO guildlogin (guilduser_name,
> guilduser_pass) VALUES ('%s', '%s')",
> $_POST['guilduser_name'],
> md5($_POST['guilduser_pass']));
> $reg = mysql_query($sql_reg) or die(mysql_error());
> }
>
> ?>
> 
> 
>  alt="pic1">
> 
> 
>
> 
>  alt="pic1">
> 
> 
> 
> 
> 
> 
> 
> New user:
> 
> 
> 
> 
> Password:
> 
> 
> 
> 
> 
>  value="update">
> 
> 
> 
> 
> 
> 
>
> 
>
> 
> 
>
> ---
> Guildlogin.php
> ---
> This should create a session variable for the authentication, but it fails
> at some point. I have checked the sessiondata on my testserver, and that
> shows blank. So it's clear for me that I don't get the information saved in
> the variable $_SESSION.
> I don't get any sql errors, so I don't think that is the problem. But then
> againit is my first script, and I could offcourse be wrong.
> I'm not sure where I should put the echo $sql; to check the query.Sincethe
> Guildlogin.php sends me directly to the error page at the end of
> execution.
> The script sends me to the loginerror.php even if the username and the
> password is correct.
> The point here is that this happens every time I press the button "login"
> in the form, regardless of the input in the form.
> 
> Code for Guildlogin.php:
> --
>  include ("connections/HOoStest.php");
>
>
>
> session_start();
> if (@$_GET['guildaction'] == "login");
> {
>
> $sql = "SELECT guilduser_name FROM guildlogin
> WHERE guilduser_name='$_POST[guilduser_name]'";
> $result = mysql_query($sql) or die("Couldn't execute query.");
> $num = mysql_num_rows($result);
> if ($num ==1) //loginname found
> {
> $sql = "SELECT guilduser_name FROM guildlogin
> WHERE guilduser_name='$_POST[guilduser_name]'
> AND guilduser_pass=password('$_POST[guilduser_pass]')";
> $result2 = mysql_query($sql) or die("Couldn't execute query 2.");
> $num2 = mysql_num_rows($result2);
> if ($num2 > 0) //password is correct
> {
> $_SESSION['auth']="yes";
> $logname=$_POST['guilduser_name'];
> $_SESSION['logname'] = $logname;
> header("Location: HolyOrder1.php");
> exit();
> }
> else //password is not correct
> {
> unset($guildaction);
> $message="Login not correct";
> header("Location: Guildloginerror.php");
> }
> }
> elseif ($num == 0) // Wrong name. Name not in db
> {
> unset($guildaction);
> $message="Login failed";
> header("Location: Guildloginerror.php");
> }
>
> }
>
> ?>
> ---
> The form:
> ---
> I don't feel it's nessesary to explain this...
> ---
> Code for loginform:
> ---
>
>  http://www.w3.org/TR/html4/loose.dtd";>
> 
> 
> HOoSloginpage for membersHOoS
> 
> 
> 
>
> 
>
>
>
>
>
>  class="maintext">
> 
>  alt="pic1">
> 
> 
>
> 
>  alt="pic1">
> 
> 
> 
>
>
> 
> 
>
> 
> 
> Login as:
> 
> 
> 
> 
> Password:
> 
> 
> 
> 
>  value="Enter">
> 
> 
> 
>
>
>
> 
> 
>
> 
>
> 
> 
> ---
> End
> ---
> I hope this was a better explanation than the last one...hehe...
> I guess I was busy pulling out my hair...
>
> -TW-
>
>
>
>


Re: [PHP] Still struggeling with my first script...

2005-10-14 Thread twistednetadmin
Well. I have figured out that the login is working as it should.
The query brings back both the username and the userpass and stores them in
$_SESSION as: auth|yes|logname|Test
When I echoed the query with both user and pass, I got both back as they
should be. In this case I ran user:Test Pass:Testing
Both came back. JOY!! :)

What I did:


if (@$_GET['guildaction'] == "login");
{
$guilduser = $_POST['guilduser_name'];
$guildpass = $_POST['guilduser_pass'];


$sql = "SELECT guilduser_name FROM guildlogin
WHERE guilduser_name='$_POST[guilduser_name]'";

$result = mysql_query($sql) or die("Couldn't execute query.");
$num = mysql_num_rows($result);

if ($num == 1) //loginname found
{

$sql1 = "SELECT guilduser_name FROM guildlogin
WHERE guilduser_name='$guilduser'
AND guilduser_pass=password('$guildpass')";
$result2 = mysql_query($sql1) or die("Couldn't execute query 2.");
$num2 = mysql_num_rows($result2);


if ($num2 > 0) //password is correct

Thanks Michael! I must have written something wrong the first time I tried
it. It seems though that it was all I needed to do.
And offcourse all the others! Thanks alot! Don't think it will be the last
time I ask about this session thing though.

-TW-


[PHP] concerning open_basedir and safe_mode on fileupload

2005-10-19 Thread twistednetadmin
I am making an imagegallery with fileuploads for the members of the site and
need a little info on how the open_basedir affects the fileupload.
I have read what I have found on it, but I'm not sure what it really does.

The phpinfo file says something like this:

PHP CORE config.
--
open_basedir (local value) /dir1/dir2/yoursite:/dir1/dir2/tempdir (master
value) No value
safe_mode (local value) On (master value) Off
-

If I understood this correctly this means that I have to upload the
imagefile to $sysfolder="/dir1/dir2/tempdir"

Or would the $sysfolder be the whole value of the (local value):
/dir1/dir2/yoursite:/dir1/dir2/tempdir

And do I then have to move the file to the wanted directory for the uploads
with a php script?

And chmod(). Is this anything to have in mind?

Final question: Wich of the values am I gonna work out from?
My guess is offcourse the (local value), or I wouldn't get the:

*Warning: *copy(): open_basedir restriction in effect.

But I would believe the (master value) WAS the master value...if you get
what I mean?
Most of the time a "mastersomething" usually overrides a
"notmastersomething" Agree?

Additional info:

The upload is from a form and works perfectly on my own testing server where
both safe_mode and open_basedir is turned of.



Can anyone explain this to me in a nice "master to noob" way? Or is more
information needed?


Re: [PHP] Re: How can I connect a remote server from phpmyadmin?

2005-10-19 Thread twistednetadmin
I asked my host to set up PHP and MySQL on the server.
They had either that or ASP with Access db.
I got an adress from them to the PHPmyadmin.
I don't think most webhosting companies allows remote access to th DB from
the local machines.
OffcourseI could be wrong...

-Twisted-


[PHP] Pictureupload

2005-11-03 Thread twistednetadmin
I have made this script to upload pictures into a picturegallery on a
website.
The script works just as I expected, but with one huge flaw. It doesn't work
from every users computer.
I can upload pictures with no problem, but another user get's an
errormessage. the other user emailed the picture to me and I could upload it
with no errors.

Here's the script.









Screenshot upload





Only pictures with the .jpg extension and size 300kb or less will be
uploaded!
Imagenames should not contain quotes or any special signs!!








File: 










Comment:













\n";
 echo "Filename: ".$_FILES['guildimage']['name']."\n";
 echo "Filesize: ".$_FILES['guildimage']['size']." byte\n";
 echo "Filtype: ".$_FILES['guildimage']['type']."\n";
 echo "Congrats! It worked!\n";
 }
 else
{

echo "Result:\n";
echo "Now that didn't seem to work... \n
Did you try a wrong format or size? \n
File that failed--> (".$_FILES['guildimage']['name'].")";

}
}

?>







Can anyone see what's wrong? Since it works from some computers and not from
all?


Re: [PHP] Pictureupload

2005-11-03 Thread twistednetadmin
The errormessage is from this part of the script.

echo "Result:\n";
echo "Now that didn't seem to work... \n
Did you try a wrong format or size? \n
File that failed--> (".$_FILES['guildimage']['name '].")";

So it seems that the file is wrong type or size, but as it works with the
same picture from my own computer that is odd.

The timeout part I have to check before I answer to, but I have 4mb
connection and the last user it failed for has a 2mb connection. 300kb
shouldn't make the script time out? Or could it? Where do I check the
timeout settings btw? PHP.ini?
Or can I run phpinfo() on it?


Re: [PHP] Re: Pictureupload

2005-11-03 Thread twistednetadmin
As I'm not the serveradmin I have only checked the phpinfo wich says:

mysql.connect_timeout60

default_socket_timeout60

Keep-Alive 300

HTTP_KEEP_ALIVE 300

Timeouts Connection: 300 - Keep-Alive: 15

Wich of these I should work out from and what they all have to say, I'm not
sure of though since I'm quite new to this.

The errormessage is written above James.


[PHP] Is there an alternative for $_FILES['guildimage']['type'] == "image/jpeg"

2005-11-22 Thread twistednetadmin
I use this line in a script for uploading pictures to a website:

$_FILES['guildimage']['type'] == "image/jpeg"

This works fine when using Mozilla, but it doesn't work with IE.
How should I do it to get it working with both/all browsers?



if (isset($_POST['submit']))//If you
press submit
{
 $sysfolder="/guildimages/";
 $filename="".$_FILES['guildimage']['name']."";

if (file_exists($sysfolder . $filename))   //And the
file exists or there is no file chosen
 {
 echo "Filename exists or no file selected. Please rename the file or select
a file";

}
 elseif ($_FILES['guildimage']['type'] == "image/jpeg") //If the
filetype is correct (this is where the change should be I think)
 {

copy ($_FILES['guildimage']['tmp_name'],
"/guildimages/".$_FILES['guildimage']['name'])//Copy the file to
folder ("/guildimages")
 or die("Could not copy file");  //Or
die

echo "Result:\n";
 echo "Filename: ".$_FILES['guildimage']['name']."\n";
 echo "Filesize: ".$_FILES['guildimage']['size']." byte\n";
 echo "Filtype: ".$_FILES['guildimage']['type']."\n";
 echo "Congrats! It worked!\n";
 }
 else
 {

echo "Result:\n";
 echo "Now that didn't seem to work... \n
 Have you checked the size and filetype? \n
 File that failed--> (".$_FILES['guildimage']['name'].")";

}
 }

Does anyone know the answer to this?


[PHP] Is there a way to determine wich browser a visitor uses in php?

2005-11-22 Thread twistednetadmin
Is it possible to use PHP to find out wich type of browser is in use?
Or must is this done by javascript or something else?
I would like to have a little statistic on my page that tells me what
browser is currently moet used.


Re: [PHP] Is there an alternative for $_FILES['guildimage']['type'] == "image/jpeg"

2005-11-22 Thread twistednetadmin
This did the trick:

elseif ($_FILES['guildimage']['type'] == "image/pjpeg" or "image/jpeg")


Re: [PHP] Is there a way to determine wich browser a visitor uses in php?

2005-11-22 Thread twistednetadmin
Thanks guys. That helps alot!

But this:


Returned this using Mozilla: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.7.12) Gecko/20050915 Firefox/1.0.7
And this using IE: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

Does that just mean that it's not completely accurate?


[PHP] Autodeleting news when it has become yesterdays news

2005-11-22 Thread twistednetadmin
I have a news-script on a webpage. Or an eventscript you might call it.
This lists up events thats gonna happen on a given day. ie concerts and
sportsevents.
To get this deleted without having to log on to the adminpage when the event
is over would have been a great relief.

1. Is it just as simple as writing a query that executes and removes news
with yesterdays date?

2. And how should I set it to execute if so?

Just at the beginning of the page with the news is my thought. So that it
checks for the eventdate and erases the overdued ones before it collects the
news.

3. Is there any pitfalls I should be aware of?

I use Mysql for my db of course.

Could someone give me a start on this?