
heldenbrau
Members-
Posts
159 -
Joined
-
Last visited
Everything posted by heldenbrau
-
Thanks, that is what I was after. But now I get the warning Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing and no email has been received. I am using my own computer as the webhost with apache. I have set the following in the ini file [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = mail.virgin.net ; http://php.net/smtp-port smtp_port = 25 and ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = [email protected] What is missing?
-
how do you get the variable from the user in verify.php when it is clicked. Like if it was a submit button name="value" value="$value". The recieving code would be $value= $_POST['value']; What would be the receiving code to receive the ?name=$username?
-
I want to send an email with PHP to verify users email addresses. I have got as far as sending the email from the script $to = "$email"; $subject = "Verification email"; $body = "<a href=\"website/verify.php?name=$username\">Click here to activate your account</a>"; if (mail($to, $subject, $body)) { echo("<p> A verification email has been sent to your email address. You need to activate your account by clicking on the link in that email. If you do not activate your account, it will expire on $present.</p>"); } else { echo("<p>Verification email failed...</p>"); If the above code is right, then how do I get the value sent by the click?
-
Hi, thanks for that, now everything is working perfectly.
-
I set pagenum in this bit if (!(isset($pagenum))) { $pagenum = 1; } Does it need to be set before the if?
-
I found some info on the internet to help me and I copied their code into one of my own pages. I am sure that I have copied it properly. But what happens is, it only ever shows the first lot of results, no matter what page it is on. If I click next page, the pagenum goes to 2, but the "<--prev" link doesn't appear and it shows the same database results as it did for page 1. This is the code: <html> <head> <style type="text/css">@import url(styles/cases.css);</style> </head> <body> <div id="masthead"> <!--#include file="cases/header.html"--> </div> <div id="sidebar"> <!--#include file="cases/sidebar.html"--><br> </div> <?php date_default_timezone_set('Europe/London'); if (!(isset($pagenum))) { $pagenum = 1; } $time = mktime()-7776000; $mysqli = new mysqli("localhost", "user", "password", "cases"); if ($mysqli === false) { die("ERROR: Could not connect to database. " . mysqli_connect_error()); } $sql="SELECT * FROM cases WHERE lastpost>$time"; if ($result = $mysqli->query($sql)) { if ($result->num_rows > 0) { $rows = mysqli_num_rows($result); }else {echo "No records matching your query were found."; } }else { echo "ERROR: Could not execute $sql . " . $mysqli->error; } $page_rows = 15; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $sql="SELECT casenum, heading,lastpost FROM cases WHERE lastpost>$time ORDER BY lastpost DESC $max"; if ($result = $mysqli->query($sql)) { if ($result->num_rows > 0) { while($row = $result->fetch_array()){ $date= date("d M Y H:i:s", $row[2]); echo"<div id=\"content\">\n <a href=\"cases/case$row[0].shtml\"<font size=\"4\">$row[1]</a> | Udated $date BST</font>\n </div>"; } $result->close(); }else { echo "No records matching your query were found."; } }else { echo "ERROR: Could not execute $sql . " . $mysqli->error; } $mysqli->close(); echo " --Page $pagenum of $last-- <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> <div id="footer"> <!--#include file="cases/footer.html" --> </div> </body> </html>
-
ok, thanks, will read up on pagination.
-
On a forum like this, at the bottom it shows page numbers. I am working on my own forum at the moment and I can't figure out how these pages can be generated. My brain can't handle it. Is there an easy way?
-
I am using apache on my laptop to test a website. It is version 2.2. I have added those lines to the httpd file. It has made an improvement, the code is displayed on the webpage, but the code isn't executed. It is like it is being done in the wrong order, like PHP first, then shtml, so the php is included after it has been exectuted, so only shows as an html page with the php code.
-
I want some php includes in my shtml files. I have the following line added in the head section of my shtml page. <MIME TYPE Extension application/x-httpd-php.html> But when I open the page, the php doesn't work. The code is not displayed though, it is only displayed in the source. The code that is in the include is Code: [select] <?php session_start(); if (!isset($_SESSION['username'])) { $username=($_SESSION['username']); echo"You are logged in as $username"; } ?> Also what do I put as the include, is it <!--#include file="file.html"--> or <!--#include file="file.php"--> I am using PHP5 and Apache2.2
-
I want to inlude some php includes in my shtml files. I have the following line added in the head section of my shtml page. <MIME TYPE Extension application/x-httpd-php.html> But when I open the page, the php doesn't work. The code is not displayed though, it is only displayed in the source. The code that is in the include is <?php session_start(); if (!isset($_SESSION['username'])) { $username=($_SESSION['username']); echo"You are logged in as $username"; } ?>
-
[SOLVED] getting database count from mysql query
heldenbrau replied to heldenbrau's topic in PHP Coding Help
Using the num rows has sorted it out. Thanks. -
[SOLVED] getting database count from mysql query
heldenbrau replied to heldenbrau's topic in PHP Coding Help
I added a record to the database, so $count should count that and = 1, it should then increment by 1 because of the $count++ so end up as 2 and print out case2. But it doesn't, it stays at 1. -
[SOLVED] getting database count from mysql query
heldenbrau replied to heldenbrau's topic in PHP Coding Help
I changed the code to below, but the $count isn't incrementing, it just stays at 0 even when there is an entry in the database. <?php $mysqli = new mysqli("localhost", "username", "password", "cases"); if ($mysqli === false) { die("ERROR: Could not connect to database. " . mysqli_connect_error()); } $sql = "SELECT * FROM cases"; $count = 0; $result = $mysqli->query($sql); while ($row = mysqli_fetch_array($result)) { $count++; } if ($count==0){ $count++; } $newcase = 'case'.$count; echo $newcase; ?> -
[SOLVED] getting database count from mysql query
heldenbrau replied to heldenbrau's topic in PHP Coding Help
Thanks for typing that out. When I run it nothing happens, is that because there is no data in the database? The only data in the database is the columns waiting to be filled. -
I want to count the amount of rows in a database and display them, then increment the number and pass it to a filename. The filename needs to be called case1, case2, case3, case4, etc. depending on how many cases are already in the database. I have tried the following code but I keep getting Parse error: syntax error, unexpected T_VARIABLE $mysqli = new mysqli("localhost", "username", "pasword", "cases"); if ($mysqli === false) { die("ERROR: Could not connect to database. " . mysqli_connect_error()); } $sql = "SELECT COUNT(*) FROM 'cases'; if ($result = $mysqli->query($sql)) { $row = $result->fetch_assoc(); $add = $row; $add ++; echo "$add"; $newcase = "case"$add; }else{ die("ERROR: Could not execute query: $sql. " . $mysqli->error); }
-
[SOLVED] How to get carriage returns from textarea input
heldenbrau replied to heldenbrau's topic in PHP Coding Help
ok, worked out how to use it now, thanks. -
[SOLVED] How to get carriage returns from textarea input
heldenbrau replied to heldenbrau's topic in PHP Coding Help
How do you use that to get the carriage returns from the $_case['textarea'] data? -
I am working from a book, but the timezone is not mentioned anywhere. So I don't understand how it works, or how you set it. I am working on creating a webpage that shows how long somebody has had an account for. Their user rating is based on how long they have been signed up. So I need to put the current timestamp into a variable and then subtract the date when they created their account.
-
This code aimed at printing a unix timestamp of todays date: $toddate= date(mktime()); echo $toddate; Produces this: Warning: mktime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for '1.0/DST' instead. I want it to print out the current date.
-
[SOLVED] Can't get PHP to print a result of an sql query.
heldenbrau replied to heldenbrau's topic in PHP Coding Help
don't worry, my fault, was using the wrong field name. It does work with dates. -
[SOLVED] Can't get PHP to print a result of an sql query.
heldenbrau replied to heldenbrau's topic in PHP Coding Help
Now I need to do the same thing, but with a date field. The fetch_assoc()) doesn't work with the date field. -
[SOLVED] Can't get PHP to print a result of an sql query.
heldenbrau replied to heldenbrau's topic in PHP Coding Help
Yay, that's done it , wish I understood it though. It'll come to me. Thanks for that. -
[SOLVED] Can't get PHP to print a result of an sql query.
heldenbrau replied to heldenbrau's topic in PHP Coding Help
After replacing the code with the above it now says undefined variable and Fatal error: Call to a member function query() on a non-object.