-
Posts
2,527 -
Joined
-
Last visited
Posts posted by DeanWhitehouse
-
-
Hi , i am making a site for someone, it is there portfolio and they are an artist, what would people recomend on how to do a photo album.
Mysql? store links in there etc.
or
would i need JS
any ideas?
-
i think you want something like this site
http://www.innovatorvillage.com/
sorry, i don't know how to do it, but it should give people the right idea
-
just to say that i have already solved this on my own, and i know CSS and what i have works.
-
yer, well it can be made more complex, and you can have it so it checks user level(or rights or whatever) and if you where admin, you can see the page properly.
-
you would put an IF at the beggining of each page and
IF($closed)
{
echo "site closed";
}
else
{
rest of code
}
that won't work as it is, but should point you in the right direction
-
erm, yer
(please anyone correct me if i'm wrong)
-
by doing a MySql query, and echoing the result in the <input value="<?php echo"$value"; ?>">
-
Can someone tell me why this code,
div.left_bar { position:absolute; left:200px; width:auto; } table.logged_in { top:; } table.left_bar { border:#00FF00 groove; background-color:#000000; top:120px; }
is only adjusting the the width of this
<table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p>
and not this
<table class="left_bar"><tr><td> <a class="nav_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <tr><td><a class="nav_bar" href="<?php echo "$home_page/forum.php"; ?>">Forum</a></td></tr> </table>
what i want it to do, is the whole nav_bar all be the same width, so if the user has a long username the whole nav bar changes width not just part of it
this is my whole code
<div class="left_bar"> <?php /*Random Game Design: PHP Website Template/CMS Version 1 Copyright Dean Whitehouse, 2008*/ if (isset($_GET['logout'])) { setcookie("uname", $_SESSION['id_username'], time() - 86400*100); setcookie("userpw", $user_password, time() - 86400*100); setcookie("check",$checked, time() - 86400*100); session_unset(); session_destroy(); } if ($_SESSION['is_valid'] == true) { if ($_SESSION['user_level'] == 2) { ?> <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> <?php } if ($_SESSION['user_level'] == 1) { ?> <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php echo "$home_page"; ?>/admin/admin_centre.php">Admin Area</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> <?php } } else { require_once 'includes/db_connect.php'; if ($_SESSION['is_valid'] == false) { if (isset($_POST['login'])) { $user_name = mysql_real_escape_string($_POST["user_name"]); $user_password = mysql_real_escape_string($_POST["user_password"]); $cookiename = forumcookie; $verify_username = strlen($user_name); $verify_pass = strlen($user_password); if ($verify_pass > 0 && $verify_username > 0) { $userPswd = md5($user_password); $userpwsd = sha1($userPswd); $sql = "SELECT * FROM $user WHERE user_name='$user_name' AND user_password='$userpwsd' LIMIT 1;"; $result = mysql_query($sql) or die(mysql_error() . " in $sql"); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); $s_userpass = serialize($userpass); $_SESSION['id_username'] = $row['user_name']; $_SESSION['id_user_password'] = $row['user_password']; $_SESSION['user_level'] = $row['userlevel']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['is_valid'] = true; //change the session variable name to what you want, just remember it for all files if (isset($_POST['remember'])) { $checked = "checked='checked'"; setcookie("uname", $_SESSION['id_username'], time() + 86400*100); setcookie("userpw", $user_password, time() + 86400*100); setcookie("check",$checked, time() + 86400*100); } header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]); } else { echo "Login failed. Username and Password did not match database entries."; } } else { echo "Form was not completed. Please go back and make sure that the form was fully completed."; } } $server = str_replace("?logout=true","",$_SERVER['PHP_SELF']); ?> <table bgcolor="#999999" align="right"><form action=" <?php echo "$server"; ?> " method="post"> <tr><td>Username: </td><td><input type="text" name="user_name" value="<?php echo $_COOKIE['uname']; ?>" /><br /></td></tr> <tr><td>Password:</td><td> <input type="password" name="user_password" value="<?php echo $_COOKIE['userpw'] ?>" /><br /></td></tr> <tr><td><input type="hidden" name="login" value="true"><input type="submit" value="Submit"></td></tr> <tr><td><input type="checkbox" name="remember" <?php echo $_COOKIE['check'] ?>> Remember Me </td></tr><tr><td><a href="register.php">[Register]</a></td></tr><tr><td><a href="forgot_password.php">[Forgot Password?]</a></td></tr></table> </form> <?php mysql_close(); } } ?> <?php require_once "includes/main.inc.php"; if ($_SESSION['is_valid'] == true){ ?> <table class="left_bar"><tr><td> <a class="nav_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <tr><td><a class="nav_bar" href="<?php echo "$home_page/forum.php"; ?>">Forum</a></td></tr> </table> <?php } else { ?> <a class="left_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <?php } ?> </div>
-
I found another code, thanks for the replys
-
Tried that, but i couldn't work out what to echo.
can anyone help, this is the code the site suggested.
if ( !isset($_SESSION['GMT_offset']) ) { $_SESSION['GMT_offset'] = 0; $_SESSION['GMT_offset_str'] = '+0:00'; } if ( isset($_GET['offset']) ) { $_SESSION['offset'] = $_GET['offset']; set_timezone($_GET['offset']); } function set_timezone( $offset ) { if ( $offset ) { $offset = -$offset; $_SESSION['GMT_offset'] = 60 * $offset; $GMT_offset_str = ( $offset > 0 ) ? '+' : '-'; $GMT_offset_str .= floor($offset / 60) . ':'; $GMT_offset_str .= (($offset % 60) < 10 ) ? '0' . $offset % 60 : $offset % 60; $_SESSION['GMT_offset_str'] = $GMT_offset_str; } } function format_datetime( $date ) { return ( date('d M Y g:ia', $date + $_SESSION['GMT_offset']) . ' GMT ' . $_SESSION['GMT_offset_str']); }
-
Does anyone have a code that will display the local time of the viewer?
And that is real time, eg. every second the seconds increase, instead of time updating on page reload.
-
thats a subdomain, not created by PHP(i don't think) but created on the host
-
looking through my other codes shows there is a table infront of the button
-
When i view my home page, the submit button isn't clickable. Can someone check if this is just me or the site.
this is the link
http://deanwhitehouse.awardspace.co.uk/home.php
this is the code for the form
<table bgcolor='#999999' align='right'><form action=" <?php echo "$server"; ?> " method='POST'> <tr><td>Username: </td><td><input type='text' name='user_name' value="<?php echo $_COOKIE['uname']; ?>" /><br /></td></tr> <tr><td>Password:</td><td> <input type='password' name='user_password' value="<?php echo $_COOKIE['userpw'] ?>" /><br /></td></tr> <tr><td><input type="hidden" name="login" value="true"><input type="submit" value="Submit"></td></tr> <tr><td><input type="checkbox" name="remember" <?php echo $_COOKIE['check'] ?>> Remember Me </td></tr><tr><td><a href="register.php">[Register]</a></td></tr><tr><td><a href="forgot_password.php">[Forgot Password?]</a></td></tr></table> </form>
-
yep, here we go
-
anyone?
-
also, i have tried using else aswell. and that didn't work.
-
ok, this is my code,
<?php if ($_SESSION['is_valid'] == false) { if(isset($_POST['signup'])) { if ($user_name && $user_password && $user_password2 && $user_email && $user_email2) { if (strstr($user_email, '@')) { $user_check = mysql_num_rows(mysql_query("SELECT * FROM $user WHERE user_email='$user_email' OR user_name='$user_name'")); $length = strlen($user_password); $length1 = strlen($user_name); if ($length >= 6) { if ($length1 >= 4) { if ($user_check >= 1) { require_once 'register.php'; echo "Sorry, but the username or email you requested is already in use. Please enter a different username."; } elseif ($user_password == $user_password2 && $user_email == $user_email2) { $userPswd = md5($user_password); $userpwsd = sha1($userPswd); mysql_query("INSERT INTO `$user` (user_id, user_name, user_password, user_email, user_ip, userlevel ) VALUES ('','$user_name','$userpwsd','$user_email','$ip','2')") or die('Error ' . mysql_error()); echo "Succesfully Registered. You will recieve a confirmation email shortly."; header ("http://".$_SERVER[HTTP_HOST].$success); } } } } } if(!strstr($user_email, '@')) { echo "Invalid Email<br>"; } if($length <= 5) { require_once 'register.php'; echo "Password Too Short<br>"; } if($length1 <= 3) { require_once 'register.php'; echo "Username Too Short.<br>"; } if(!$checkpw) { require_once 'register.php'; echo "The passwords you entered do not match. Please check these details and try again.<br>"; } if(!$checkem) { require_once 'register.php'; echo "The emails you entered do not match. Please check these details and try again.<br>"; } else { require_once 'register.php'; echo "Please fill in all of the required fields."; } } ?>
Can someone see if they can see why it isn't working properly, my problem is that it echoes some of the other IF's , if the email is incorrect. i have tried for a long time to try and fix it, can someone just have a look and see.
-
I no how to do if-else, but i want the code to check each bit, but anway.
How can i stop these errors appearing when the user enters nothing
Warning: preg_match() [function.preg-match]: Empty regular expression in /home/www/deanwhitehouse.awardspace.co.uk/register.php on line 80
line 80
if (!preg_match($checkmail, $user_email)) { echo "Invalid e-mail address<br>"; }
-
As i thought that code doesn't work, it now doesn't echo anything or do anything.
Please check your code before posting, and stop with the comments. I dunno what you have against me.
This is how if-else statements should be writte, and not write 100 if() without having an idea what ure doing. Why double check, theres no need!
-
soz, i thought that ==0 did't work,
Blade, try the code before posting, as soon as ure not experienced with php. In your two last posts, ure wrong, not the OP. $this==$that will work and so will do the if-else statement that he wrote.
Alexhoward, Undefined index: example means that the index 'example' does not exist in $_GET array. I dont see a <form> in your code so i guess thats the problem.
it's my fault i was wrong, i thought that didn't work, and i wasn't going to try the code as i am just looking and saying what i thought was wrong. And i never said the if=else statement wouldn't work, i said it was wrong ,the correct way to write it is with the {}
-
so what part of this code doesn't work?
-
yer, but you will need to know what to delete from the code.
-
this is wrong
if(mysql_num_rows($res)==0) echo "there is no data in table.."; else for($i=0;$i<mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); echo"<option>$row[cat]</option>"; } ?>
it should be
if(mysql_num_rows($res)==0) { echo "there is no data in table.."; } else { for($i=0;$i<mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); echo"<option>$row[cat]</option>"; } ?>
[SOLVED] str_replace with blank characters
in PHP Coding Help
Posted
$logout = str_replace("?logout","","");
this is my code, i want to delete the ?logout, how can i do this(am i using the wrong code).
example
http://mysite.com/members?logout
should change to this
http://mysite.com/members