Great :) Can you mark the thread as solved please?
BenzZz commented: Well explained! +3
simplypixie 123 Posting Pro in Training
Great :) Can you mark the thread as solved please?
Not quite - you have some strange things going on with your echo and can I also suggest that you always ope your PHP tags with <?php, not short tags. I have re-jigged things for you to sort it out and make it cleaner and easier for you to understand (I hope ;) )
<?php
if (isset($_SESSION['lastname']) && !empty($_SESSION['lastname'])) {
?>
<div class="login"><a href="login-register-page.php" >Logout</a></div>
<div class="createbar"></div>
<img class="create_s" src="styles/Images/create_s.png" alt="creates"/>
<div class="create"><a href="login-register-page.php" >Welcome</a><span class="style2">
<?php echo $_SESSION["lastname"]; ?>
</span></div>
<?php } else { ?>
<div class="login"><a href="login.php" >Login</a></div>
<div class="createbar"></div>
<img class="create_s" src="styles/Images/create_s.png" alt="creates"/>
<div class="create"><a href="login-register-page.php" >Create an account</a></div>
<?php } ?>
Why not search what Undefined Index means - there are very easy to understand explanations if you just Google it.
if (isset($_SESSION['lastname']) && !empty($_SESSION['lastname'])) {
// Welcome lastname
} else {
// display login
}
If you read my tutorial as in the link in my last post it explains how to do it.
Have you got session_start(); at the top of every page? And then have you checked that you have a value in the lastname session? You may want to read my tutorial on how to format and check these things here
Exactly and then change
<div class="create"><a href="login-register-page.php" >Welcome</a><span class="style2"><?php echo $_SESSION["email"]; ?> </span></div>
</div>
To
<div class="create"><a href="login-register-page.php" >Welcome</a><span class="style2"><?php echo $_SESSION["lastname"]; ?> </span></div>
</div>
I am still not entirely sure what you are counting for as you don't seem to have more than one record per vreg and you are not updating in your while statement.
Plus I have changed your mysql_numrows (INCORRECT) to mysql_num_rows more than once now but you still have the incorrect code.
What is your reason for it? And why would you want to return a count from your db query which will only return one result and then use mysql_num_rows anyway?
Can you just explain a little more exactly what you are trying to do here?
You need to change the session to set to the firstname instead of email or add it as an additional session variable.
That is because even though you have set you list items to be displayed inline, you have done nothing with the actual unordered list tag so it will automatically put it below you text.
Try adding display: inline; to your ul tag css.
Glad I could help :)
Yes I am, it is awful if you are new to PHP. It doesn't explain things properly for those who are learning.
OK to format the date and time as 13/01/2012 08:15 AM using 24 hour format (for example), $row would be the variable you are storing your result from the database in:
$datetime = date('d/m/Y H:i A', strtotime($row['datetime']));
echo $datetime;
If you only need the date then take out H:i:A
To change it back to insert into the database
$datetimefordatabase = strtotime($_POST['date_time']);
Even though php.net is a nightmare to use, their list of date and time formats is useful and can be found here
Not quite
$query= "UPDATE rpms SET quantity=quantity+'$quantity' WHERE product_name='product_name'"
Graphix - sorry that you are disappointed that I provided an answer for the OP and felt you had to give me a negative reputation on it, but as far as I am concerned that is what I am on this forum for, not to provide full code but help people as much as I can in the simplest way I can as I would have like to have been helped when I was starting out.
It is all well and good telling people to google but have you ever thought that they may have already done that and not been able to understand exactly how they needed to resolve their problem, I personally think php.net is an awful site to try and learn from.
I can't flag the post as bad as it is not a post it is a reputation comment. It doesn't matter, I just wanted to know if I could dispute or not and it appears not and even if the person who made the reputation comment comes round then they can't retract it anyway.
What exactly is the problem? For example do any of your errors display or does it appear to go trhough but doesn't actually update?
There are actually 2 errors in your code that I can see
else
if($password != mysql_result($result, 0)){
echo "Entered an incorrect password";
}
You are missing the surrounding parenthesis for your else statement
else {
if($password != mysql_result($result, 0)){
echo "Entered an incorrect password";
} }
Then you are saying if not $sql the success, should be the other way around
if($sql){
echo "Congratulations, password successfully changed!";
}
WaltP - you make a good point, thank you. Can I just ask what you mean about going through the right channels to have it reversed/removed? Are you suggesting I contact Daniweb administrators directly?
That is because you haven't specified the columns in your insert query
$sql = "insert INTO sre_log
values('$com_name','$loc','$name_mech','$vtype','$s_veration','$remnder_ver','$vreg','$last_startdate','$mileage','$current_mileage','$cur_date')";
The above is wrong and should be
$sql = "insert INTO sre_log (com_name, loc, name_mech, vtype, s_veration, remnder_ver, vreg, last_startdate, mileage, current_mileage, cur_date) values('$com_name','$loc','$name_mech','$vtype','$s_veration','$remnder_ver','$vreg','$last_startdate','$mileage','$current_mileage','$cur_date')";
Also, are you sure you have all the columns that are actually in the table?
If you provide us with your code and tell us what isn't working we may be able to help. Have you even looked at the Paypal documentation showing you how to do it?
It needs to be at the very top of the page and you need to ensure you are not calling it more than once (i.e. from an included file). So you would have something like
<?php
session_start();
//followed by your include/require files and any other PHP
?>
<!-- Your HTML page starts here -->
Not much point I don't think as they can't remove their reputation comment
I thought about that but then thought it unfair as would essentially be hijacking the thread. Oh well I will just have to fume in silence (there are only 2 comments and both ridiculous but just felt I would like to respond to them if I could).
ALso, I have answered this question (or similar) about 3 times recently on this forum - have you tried searching the forum for the answer?
You need session_start() at the top of every page where you use sessions and no you don't need session_regenerate_id() (that question was in case you were using it in error).
Is there any way to respond to reputation comments as I feel it a little unfair that if someone writes a comment about a post I have made that I feel is unjustified that I can't respond to it (unless I am missing something)? Or even a way to dispute a negative mark and comment?
But that doesn't mean anything - what is the exact problem you are having?
You could put it into a div or class instead of the table (I can't answer your question as it is years since I put a background image set to a table cell).
A pritaeas says - lines 14 and 19, however I will expand and let you know that the errors are due to missing closing parenthesis on both lines.
Use $_POST to get the values submitted in the form (use for each field name and replace the word fieldname with your actual field names).
As veedeoo said, or try putting the if statement outside your img tags
<?php if $row_rs_dresses['prod_status'] == "Sold") { ?>
<img src="images/outofstock.gif" width="40" height="40" />
<?php } else { ?>
<img src="images/dot.gif" width="40" height="40" />
<?php } ?>
Can't solve what?
I see what you are doing now and there is no reason or need to have a whole html page echoed in php so change (plus you are correct you can't use <?php ?> within other php tags but the way you are doing things you also need to end and restart <<< HTML each time you want to echo php.
Change both your registration and registration failed pages.
Registration:
<?php
require_once('InitDB.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Member Login</title>
<link rel="stylesheet" type="text/css" media="screen" href="registration.css" />
</head>
<body>
.
.
.
.
.
.
</body>
</html>
Fail page:
<?php
require_once('InitDB.php');
session_start();
$errmsg1 = $_SESSION['ERR_MSG1'];
$errmsg2 = $_SESSION['ERR_MSG2'];
$errmsg3 = $_SESSION['ERR_MSG3'];
$errmsg4 = $_SESSION['ERR_MSG4'];
$errmsg5 = $_SESSION['ERR_MSG5'];
$ovrerrmsg = $_SESSION['OVR_ERR_MSG'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Member Login</title>
<link rel="stylesheet" type="text/css" media="screen" href="registration.css" />
</head>
<body>
.
.
.
.
.
</body>
</html>
Sorry posted my first reply at the same time as you posted again so may not be relevant now.
This won't work though
<p class = "instructions">
$_SESSION['OVR_ERR_MSG']
</p>
You have no PHP tags, should be
<p class = "instructions">
<?php echo $_SESSION['OVR_ERR_MSG']; ?>
</p>
You shouldn't just be echoing out the errors without checking if they have any data first. For example, change this
<?php echo $errmsg1; ?>
To this:
<?php if (isset($_SESSION['ERR_MSG1']) && !empty($_SESSION['ERR_MSG1'])) {
echo $_SESSION['ERR_MSG1'];
}
And see what happens (you will obviously need to change them all or the one that you know will have data to test.
Sorry, I can see them now. Have you tried using var_dump($_SESSION) at the top of the page (after session_start()) to ensure that your session data is there?
Firstly, there is no need to re-assign your session variables to normal variables, just use them as they are. Secondly, and more importantly, I cannot see anywhere on the page that actually echos the error messages which is why you won't see them.
You would be much better off learning CSS (plenty of information on the web) as even with a simple template you won't necessarily know what is doing, how to use it or how to make any additions or changes to the style sheet should you need to.
What you are saying you want to do will cause your above script not to work as it is more complicated than just being able to rely on a count.
Presumably each record has an id set as a primary key (I hope anyway) as you will need to use this and change your query. You will need to select * (rather than using a count) and get the last record so that you can just use that one to see if it can be updated or whether you need to create a new record. Obviously you will also need to check if a record exists at all still.
Something like (this is not tested but hopefully gives you an idea of what I mean):
$insert=0;
$sre_log_result = mysql_query("select * FROM sre_log WHERE vreg ='$vreg' ORDER BY '$id' DESC LIMIT 1");
$sre_log_num = mysql_num_rows($sre_log_result);
if ($sre_log_num > 0) {
$record = mysql_fetch_array($sre_log_result);
if (isset($record['current_mileage']) && $record['current_mileage'] != '') {
$insert = 1;
}
} else {
$insert = 1;
}
if ($insert == 1) {
$sql = "insert INTO sre_log
values ('$com_name','$loc','$name_mech','$vtype','$vreg','$last_startdate','$due_end_date','$current_mileage','$cur_date')";
} else {
$sql = "UPDATE sre_log SET com_name='$com_name',loc='$loc',name_mech='$name_mech',vtype='$vtype',last_startdate='$last_startdate',due_end_date='$due_end_date',mileage='$current_mileage',cur_date='$cur_date' WHERE vreg='$vreg'";
}
mysql_query($sql);
No problem - I remember what it is like to be a noob and also miss things that can seem obvious once pointed out.
The only thing I can think is that these 2 lines don't match
function get_content($id = " "){
if ($id != ""):
You are saying if no id is sent through the id equals space but then you want id to be nothing in your if statement, try taking out the space in the function
function get_content($id = "")
ardav means
mysql_numrows
is wrong, it doesn't do or mean anything as it should be
mysql_num_rows
What is the point of using ON DUPLICATE KEY UPDATE when all you have to do is use an update query?
You also have mysql_QUERY which should be mysql_query in line 4 and this code is pointless
$i = 0;
while($i < $sre_log_num)
{
$counter = mysql_result($sre_log_result,$i,"counter");
$i++;
}
All you need is
while($row = mysql_fetch_array($srelog_result))
{
$counter ++;
}
Yes, so did I
The code works but what I want to do is to exclude 'Northern Lights' from the result
Quite simple in their requirements I think
This is nothing to do with CSS, you need to check the HTML for each page and change the link name back to having a capital first letter. For example, in products.html you need to change products to Products in the navigation on that page.
This is wrong:
mail($to, $subject, $body,"From: $email")
You need headers and then change the above:
$headers = "From: <$from>\r\n";
$headers.= "Reply-To: youremailaddresshere\r\n";
$headers.= 'Content-type: text/plain;charset="iso-8859-1"';
mail($to, $subject, $body, $headers);
How do you know that is what they really want and have therefore completely over-complicated the code the OP posted?
Use != for 'Not equal to'.
Change this
WHERE bt1.btName = 'Northern Lights'
to this
WHERE bt1.btName != 'Northern Lights'
Not sure what the extract is for, it is as simple as
while ($row = mysql_fetch_array($results))
{
echo $row['Number'].' - '. $row['Name'].' - '. $row['Address'].'<br>';
}
You also need to clean up your HTML (i.e. get rid of all those $nbsp;)
It generally means your password is wrong