[oclug] Linux Server or PHP?
Zhimmy Kanata
kanata_zhimmagish at yahoo.ca
Thu Apr 5 20:40:56 EDT 2007
Hi,
Those <---- I put in just to help whomever was willing to give me a ear. They aren't in my program I have running on the server.
I got the code from a place called www.avengingsorrow.com
Thanks for you time and any other advice you have is greatly appreciated.
Cheers
Zhimmy
The Linux Doctor <linuxdoctor at linux.ca> wrote:
On Thu, 5 Apr 2007 19:53:51 -0400 (EDT)
Zhimmy Kanata wrote:
> Hi,
>
> I'm running into an interesting problem..Maybe its just me..
>
> But in the program below I have passed a $email into the mail() function. The server runs the function and its suppose to send a email to whoever is listed in $email...its running the function and delivers nothing!? I would have thought that if it wasn't running the function it would display and internal error message? So is it me..which I imagine it is or is it the server? Hmmm.... my code is listed below. If can anyone can help it would be apprecatied.
>
> > require("config.php");
> require("functions.php");
>
Well, for starters, where is this from? phpNuke or one of it's clones?
PHP is pretty dumb when it comes to syntactic analysis. Sometimes it
picks up errors other times it doesn't.
I'm currently working on a website that worked properly only because a
particular module PHP module had the right number of quote marks to
cover over the syntax errors. The programmers of the site were too
inexperienced to understand the problem and kluged all sorts of work
around patches until it worked.
Needless to say, when I touched the thing it all fell apart.
Neither I nor anybody here is going to count your quotes.
In any case, check this
"<--- I echo it and it displays it..must be being passed down. "
>>>-fja->
> //echo some styles to spice it up...
> echo "
>
> body
> {
> background: #131313;
> font-family: Verdana, Arial;
> font-weight: bold;
> font-size: 9px;
> color: #FFFFFF;
> }
>
> .register_box
> {
> border: 1px solid #323232;
> background: #202020;
> font-family: Verdana, Arial;
> font-weight: bold;
> font-size: 9px;
> color: #FFFFFF;
> }
>
> ";
> switch($_GET['action'])
> {
> case "new":
> //--------------------------------------
> //[New Registration]
> //--------------------------------------
> if(!isset($_POST['register']))
> {
> echo "
>
> Username:
> [input]
>
> Email:
> [input]
>
> Password:
> [input]
>
> [input]
>
> ";
>
> }
> elseif(isset($_POST['register']))
> {
> $username = mysql_real_escape_string($_POST['username']);
> $password = mysql_real_escape_string($_POST['password']);
> $email = mysql_real_escape_string($_POST['email']);
> $activation_code = generateCode(25);
>
> $userq = "SELECT username FROM user_system WHERE username = '$username' LIMIT 1";
> $emailq = "SELECT email FROM user_system WHERE email = '$email' LIMIT 1";
>
> //put errors into an array
> $errors = array();
> if(empty($username))
> {
> $errors[] = "The username field was blank!
";
> }
> if(mysql_num_rows(mysql_query($userq)) > 0)
> {
> $errors[] = "The username given is already in use! Please try another one!
";
> }
> if(empty($password))
> {
> $errors[] = "The password field was blank!
";
> }
> if(empty($email))
> {
> $errors[] = "The email field was blank!
";
> }
> if(mysql_num_rows(mysql_query($emailq)) > 0)
> {
> $errors[] = "The email given is already in use! Please try another one!
";
> }
> if(count($errors) > 0)
> {
> foreach($errors as $err)
> {
> echo $err;
> }
> }
> else
> {
> $sqlq = "INSERT INTO user_system (username, password, email, is_activated, activation_code)";
> $sqlq .= "VALUES ('$username', '".md5($password)."', '$email', '0', '$activation_code')";
> mysql_query($sqlq) or die(mysql_error());
>
>
> echo "$email"; <--- I echo it and it displays it..must be being passed down.
>
>
>
> echo "Thanks for registering!
> You will recieve an email shortly containing your validation code,
> and a link to activate your account!";
>
>
> mail($email, "New Registration, www.sitename.ca", " <--Doesn't work
> Thanks for registering on SITE NAME.
> Here are your login details:
>
> Username: ".$username."
> Password: ".$password."
>
> In order to login and gain full access, you must validate your account.
>
> Click here to validate:
>
> http://www.sitename.ca/register.php?action=activate&user=".$username."&code=".$activation_code."
>
> Thanks!
>
> [Webmaster]
> ");
>
> }
> }
> break;
>
> case "activate":
> //--------------------------------------
> //[Activate Account]
> //--------------------------------------
> if(isset($_GET['user']) && isset($_GET['code']))
> {
> $username = mysql_real_escape_string($_GET['user']);
>
> if(mysql_num_rows(mysql_query("SELECT id FROM user_system WHERE username = '$username'")) == 0)
>
> {
> echo "That username is not in the database!";
> }
> else
> {
> $activate_query = "SELECT is_activated FROM user_system WHERE username = '$username'";
> $is_already_activated = mysql_fetch_object(mysql_query($activate_query)) or die(mysql_error());
>
> if($is_already_activated->is_activated == 1)
> {
> echo "This user is already activated!";
> }
> else
> {
> $code = mysql_real_escape_string($_GET['code']);
> $code_query = "SELECT activation_code FROM user_system WHERE username = '$username' LIMIT 1";
> $check_code = mysql_fetch_object(mysql_query($code_query)) or die(mysql_error());
>
> if($code == $check_code->activation_code)
> {
> $update = "UPDATE user_system SET is_activated = '1' WHERE username = '$username'";
> mysql_query($update) or die(mysql_error());
> echo "User $username has been activated! Thanks! You may now login!";
> }
> else
> {
> echo "The activation code was wrong! Please try again!";
> }
> }
> }
> }
> else
> {
> echo "No ID or user given to activate!";
> }
> break;
> }
> ?>
>
>
> ---------------------------------
> Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail
> --
> OCLUG general discussion list
> OCLUG at lists.oclug.on.ca
> http://www.oclug.on.ca/mailman/listinfo/oclug
--
I have been long convinced that institutions that are
purely democratic must, sooner or later, destroy
liberty, or civilisation, or both. -- Lord Acton
--
OCLUG general discussion list
OCLUG at lists.oclug.on.ca
http://www.oclug.on.ca/mailman/listinfo/oclug
---------------------------------
Make free worldwide PC-to-PC calls. Try the new Yahoo! Canada Messenger with Voice
---------------------------------
Share your photos with the people who matter at Yahoo! Canada Photos
More information about the OCLUG
mailing list