-
Posts
2,527 -
Joined
-
Last visited
Everything posted by DeanWhitehouse
-
how would i do that? <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form id="form1" name="form1" method="post" action="add_topic.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#E6E6E6"><strong>Create New Topic</strong> </td> </tr> <tr> <td width="14%"><strong>Topic</strong></td> <td width="2%">:</td> <td width="84%"><input name="topic" type="text" id="topic" size="50" /></td> </tr> <tr> <td valign="top"><strong>Detail</strong></td> <td valign="top">:</td> <td><textarea name="detail" cols="50" rows="3" id="detail"></textarea></td> </tr> <tr> <td><strong>Name</strong></td> <td>:</td> <td><input name="name" type="text" id="name" size="50" /></td> </tr> <tr> <td><strong>Email</strong></td> <td>:</td> <td><input name="email" type="text" id="email" size="50" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </td> </form> </tr> </table> the form that is sent. i don't want to show them the time when it is sent
-
well this is the page where the date is inserted. <?php require_once 'db_connect.php'; require_once 'config_table.inc.php'; // get data that sent from form $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $email=$_POST['email']; $datetime=date("jS of M Y h:ia e"); //create date time $sql="INSERT INTO $forum_quest(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')"; $result=mysql_query($sql); if($result){ echo "Successful<BR>"; echo "<a href=main_forum.php>View your topic</a>"; } else { echo "ERROR"; } mysql_close(); ?> could i change it to this <?php require_once 'db_connect.php'; require_once 'config_table.inc.php'; // get data that sent from form $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $email=$_POST['email']; $datetime=?><html><script type="text/javascript"> var d = new Date(); document.write(d.getHours()); document.write("."); document.write(d.getMinutes()); document.write("."); document.write(d.getSeconds()); </script> </html>//create date time <?php $sql="INSERT INTO $forum_quest(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')"; $result=mysql_query($sql); if($result){ echo "Successful<BR>"; echo "<a href=main_forum.php>View your topic</a>"; } else { echo "ERROR"; } mysql_close(); ?>
-
but if i use javascript, i can't insert that into a database
-
Logout on the page the user is on
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
wot i ment, was so when they log out they go to the page they where just on before they clicked logout -
I have a logout script <?php require_once ""$_SERVER[REQUEST_URI])""; session_destroy(); ?> but that one doesn't work, how can i log them out on the same page they came from
-
Only let certain sites see my page
DeanWhitehouse replied to php_wanna_be's topic in PHP Coding Help
could you use .htaccess to give people access to a page when they have brought something in an online shop, and check whether they came from the shop and if they brought this item??? SORRY TO INTERUPT YOUR THREAD -
i have a code to write the time of a post to a database, this code is meant to detect time zones, but it doesn't detect daylight saving. How can i add this $datetime=date("jS of M Y h:ia e"); e is the code for the timezone detection
-
with this code, i get the else function, how can i find where the error is? <?php require_once 'db_connect.php'; require_once 'config_table.inc.php'; // get data that sent from form $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $email=$_POST['email']; $datetime=date("d/m/y h:i:s"); //create date time $sql="INSERT INTO $forum_quest(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')"; $result=mysql_query($sql); if($result){ echo "Successful<BR>"; echo "<a href=main_forum.php>View your topic</a>"; } else { echo "ERROR"; } mysql_close(); ?>
-
this is my code, does anyone no why it isn't working <?php require_once 'db_connect.php'; require_once 'config_table.inc.php'; $sql="SELECT * FROM $forum_quest ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td> </tr> </table>
-
this should send you in the right direction <?php $Search = mysql_query( "SELECT DISTINCT Courses.Course_Name, student_courses.Course_ID, student_courses.Student_ID, students.Enrollment, students.First_Name, students.Last_Name FROM Courses INNER JOIN student_courses ON Courses.Course_ID = student_courses.Course_ID INNER JOIN students ON student_courses.Student_ID = students.Student_ID WHERE Courses.Course_ID='$Course'") or die(mysql_error()); echo "<table border='0'> <tr align='center'> <td width='20%'><font color='#FFFFFF' face='Calibri'> <b>Enrollment No </td><td width='20%'><font color='#FFFFFF' face='Calibri'> <b>First Name </td><td width='20%'><font color='#FFFFFF' face='Calibri'><b>Last Name</td></tr>" while($row = mysql_fetch_assoc($Search)) $sql = mysql_query(SELECT DISTINCT/*put where the attendance data is coming from here*/); or die(mysql_error()); if ($sql == 1)/*this is the data from the database, 1 = present*/ { echo "<tr align='center'> <td><font color ='White' face = 'calibri'> $row['Enrollment']; </td><td><font color ='White' face = 'calibri'> $row['First_Name']; </td><td><font color ='White' face = 'calibri'> $row['Last_Name']; </td></tr><tr><td><font color ='White' face = 'calibri'>Present </td></tr></table></font>"; } elseif ($sql == 2))/*this is the data from the database, 2= not present*/ { echo "<tr align='center'> <td><font color ='White' face = 'calibri'> $row['Enrollment']; </td><td><font color ='White' face = 'calibri'> $row['First_Name']; </td><td><font color ='White' face = 'calibri'> $row['Last_Name']; </td></tr><tr><td><font color ='White' face = 'calibri'>Absent </td></tr></table></font>"; } ?>
-
[SOLVED] Use GET to display a page, some reason doesn't work.
DeanWhitehouse replied to MadnessRed's topic in PHP Coding Help
wheres it getting the data from?? -
erm, can you post the code you already have and i can edit to show you
-
use an if and else statement depending on the query
-
[SOLVED] Use GET to display a page, some reason doesn't work.
DeanWhitehouse replied to MadnessRed's topic in PHP Coding Help
change = to == this might work -
to make the code look nicer and just a helpfull tip, you can have the whole form in one echo instead of seperate lines
-
ok, thanks for all the help.
-
ok, thanks, this is now my working code <?php require_once 'includes/config_table.inc.php'; require_once 'includes/db_connect.php'; mysql_query("SELECT * from `$user` WHERE user_name='$user_name'"); if ($_SESSION['is_valid'] == true){ if ($_SESSION['user_level'] == 2){ echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } if ($_SESSION['user_level'] == 1){ echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } } else { include_once ('login.php'); } ?> how can i display the user name of the user, i am using sessions and cookies
-
when i remove the curly bracket i get this error Parse error: syntax error, unexpected $end in /home/www/deanwhitehouse.awardspace.co.uk/logged_in.php on line 26 and you can write includes and requires without the brackets
-
ok, people ignore the sql statement,
-
the table name is saved as a variable, so no to "SELECT * FROM users and i want to display the users username, but i can't think of a way to. Anyway back to the main problem, of the login page not displaying
-
<?php if ($_SESSION['is_valid'] == true){ if ($_SESSION['user_level'] == 2){ mysql_query("SELECT * from `$user` WHERE user_name"); echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } if ($_SESSION['user_level'] == 1){ mysql_query("SELECT * from `$user` WHERE user_name"); echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } else { include_once'login.php'; } } ?> this code is ment to display a login form if the user is not logged in, but it doesn't, and i dunno why