Jump to content

2 prob basic probs - im a newb learning :D


PaXo

Recommended Posts

ok, first problem is the login:

 

ill tell you how my site is setup first so it all makes sence:

 

this is the folders:

 

cod4 (main - with index.php and viewuser.php so far)

-layout(sub folder with header.php and footer.php)

-blocks (sub folder with stuff like latest news)

--login (sub folder in blocks which is where login.php is)

 

ok, in index.php i have my login.php a included in the code and this is the only way i could think of doing it so it would work (please give me ideas if its not the only way) but i still cant get this to work (its the submit button (which is an image) which dosnt work):

 

 

<?php

if($_POST['submit']){

?>

 

<div id="login">

Incorrect information

<META HTTP-EQUIV="refresh" CONTENT="3;URL=index.php">

</div>

 

<?php

}

else{

?>

 

<div id="login">

<form action="login.php" method="post">

<input type="text" class="text-inp" name="username" value="USERNAME" />

<input type="password" class="text-inp" name="password" value="PASSWORD" />

<input type="image" src="./images/button_input_bg.gif" class="button" name="submit" value="" />

</form>

</div>

 

<?php

}

?>

 

thats the first problem which i cant get to work, when you click the submit button, it dosnt do anything and it still shows the login box :/

 

--

 

this is the second problem, in my database i have the user_id which is 1 and the user_nickname which is Administrator and for some reason, this code is giving this error message:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\cod4\viewuser.php on line 19

 

this is the whole script:

 

<?php

include('layout\header.php');

session_start();

?>

<!-- OP:MIDDLE COLUMN -->

<div id="middle">

<h2>User Profile</h2>

<div class="main">

<div class="inner">

<img src="images/main_cont_bg_top.gif" alt="" />

<!-- INSERT MAIN CONTENT HERE -->

<?php

 

$user_id = $_GET['id'];

 

$query = 'SELECT * FROM users WHERE user_id = $user_id ORDER BY user_id';

$result = mysql_query($query);

 

while($row=mysql_fetch_array($result))

{

$user_nickname = $row['user_nickname'];

}

 

?>

 

<h3><?php echo $user_nickname; ?></h3>

 

<!-- / INSERT MAIN CONTENT HERE -->

<img src="images/main_cont_bg_bottom.gif" alt="" />

</div>

</div>

<!-- OP:EDIT FLAG 2 -->

 

<!-- END OP:EDIT FLAG 2 -->

</div>

<!-- / OP:MIDDLE COLUMN -->

<?php

include('layout\footer.php');

?>

 

the url im using is http://localhost/cod4/viewuser.php?id=1 but i cant think why it wont work.

any help is really greatful.

 

thanks

 

Link to comment
Share on other sites

On the first one, you shouldnt do the login.php as an include, if you're referencing login.php as an action then it should just be a seperate file. Asyou have it written there, then the file should be in the same directory as index.php

 

The second problem is caused (I think) by the fact you're using the include before the session_start() try swapping those two lines around, Im sure the session_start cannot come after you've written anything to the browser?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.