HoTDaWg
-
Posts
275 -
Joined
-
Last visited
Posts posted by HoTDaWg
-
-
is it my script thats wrong, because it does not send the email but inserts the data into the db...could it be the code?
<?php $ip = $_SERVER['REMOTE_ADDR']; $date = date('l F, Y @ g:i:s A e'); $sitename = "*******"; $slogan = "Making Pixels Dance."; $subscribetext= "Join...NOW!"; $emailform = '<form method="POST" name="addsubscriber" action="'.$_SERVER['PHP_SELF'].'?mode=emailsubmit"><br>'.$subscribetext.'<br>Email:<input name="emailaddress" maxlength="80" value="'.$email.'"><br><input type="submit" value="Submit!"></form>'; $conn = mysql_connect("localhost","********","****************"); mysql_select_db("**************); $adminemail = '****************'; define(inStereo,true); $mode = $_GET['mode']; switch ($mode){ case 'emailsubmit': $email = $_POST['emailaddress']; $emailerror = array(); if(empty($email)){ $emailerror['email'] .= '<li><font color="#FF0000">The Email field was was not complete</font></li>'; } if(strlen($email) > 80){ $emailerror['email'] .= '<li><font color="#FF0000">The Email field exeeds the limit of 80 characters</font></li>'; } if(preg_match('|[^-_.@a-z\d]|i', $email)){ $emailerror['email'] .= '<li><font color="#FF0000">The Email Field contains invalid characters. Alphanumeric, @,-,and _ characters are the only characters accepted due to security reasons.</font></li>'; } $emailexists = "SELECT email FROM subscribers WHERE email='$email'"; $selectemailexists = mysql_query($emailexists,$conn); if(mysql_num_rows($selectemailexists) > 0){ $emailerror['email'] .='<li><font color="#FF0000">This Email is already registered as a subscriber.</font></li>'; } if(count($emailerror) < 1){ $usercode = rand(0,1000000); $status = 'blank'; $insertemail = "INSERT INTO subscribers(`id`,`email`,`usercode`,`date`,`ip`,`status`) VALUES('','$email','$usercode','$date','$ip','$status')"; $insertemailnow = mysql_query($insertemail,$conn); if($insertemailnow){ $message="Thanks for registering on our website! Open a new window and go to http://www.slicksilver.uni.cc/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks."; $to = &$email; $subject = 'Validate This Email'; $headers = 'From: *******' . "\r\n" . 'Reply-To: *************' . "\r\n" . //This statement helps out with spam filters 'X-Mailer: PHP/' . phpversion(); //Send the email mail($to, $subject, $message, $headers); $contentecho .='Thank you for registering. A verification email has been dispatched to your email address. Please check your spam/junk mail folders if the email does not appear in your inbox. If the email does not appear at all within 24 hours contact the administrator. Thanks again.'; }else{ $contentecho .='An error occurred with your submission. Please try again.'; } }else{ foreach ($emailerror as $error){ $echoemailerrors .= ''.$error.''; } $content = array(); $content['text'] .= 'The following errors were found in your submission:<br>'.$echoemailerrors.'<br>'; $content['text'] .= ''.$emailform.''; foreach ($content as $text){ $contentecho .= ''.$text.''; } } break; case 'verify': $usercode = $_GET['usercode']; $email = $_GET['email']; $validateerror = array(); if(empty($usercode) || empty($email)){ $validateerror['empty'] .= '<li><font color="#FF0000">This page was accessed incorrectly.</font></li>'; } $validatetrue = "SELECT email,usercode FROM subscribtions WHERE email='$email' usercode='$usercode' status='good'"; $validatetruenow = mysql_query($validatetrue,$conn); if(mysql_num_rows($validatetruenow) > 0){ $validateerror['already_exists'] .= '<li><font color="#FF0000">This email is already subscribed and validated.</font></li>'; } if(count($validateerror) > 0){ $status = "good"; $updateemail = "UPDATE subscribers SET status='$status' WHERE usercode='$usercode'"; $updatemailnow = mysql_query($insertemail,$conn); if($updateemailnow){ $action = "New Email added to subscribers list"; $insertaction = "INSERT INTO actions(`id`,`action`,`date`,`ip`) VALUES('','$action','$date','$ip')"; $actionsubmit = mysql_query($insertaction,$conn); if($actionsubmit){ $contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.'; }else{ $contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.'; } }else{ $contentecho .='<li><font color="#FF0000">An error occurred with your verification. Please try again.</font></li>'; } }else{ foreach($validateerror as $errorkind){ $contentecho .= ''.$errorkind.''; } } break; default: $contentecho .=''.$emailform.''; break; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Welcome!</title> </head> <body bgcolor="#999999" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <center> <table width="750" height="0" cellpadding="0" cellspacing="0" border="0" style="Border: 1px solid #000000;"> <tr> <td bgcolor="#666666" valign="top"><font color="#FFFFFF" face="arial"><b>Under construction</font></b></td> </tr> <tr> <td bgcolor="#cccccc" valign="top"> <table width="98%" border="0"> <font face="arial" size="3"> Our website is under construction, bare with us as we create it.<b>Thanks for your consideration.</b><br> <b>Check back soon!</b><br><br> <i>The <?php echo $sitename; ?> Team</i></font> </table> </td> </tr> <tr> <td bgcolor="#0099FF" valign="top"><font color="#FFFFFF" size="3" face="arial"><B>Sign up for email updates today!</B></font></td> </tr> <tr> <td bgcolor="#CCCCCC" valign="top"> <center> <table width="98%" border="0"> <?php echo $contentecho; ?> </table> </center> </td> </tr> </table> </center> <h4 align="center">Our website is graciously hosted by <a href="http://guildwutang.com/">X ER Game Hosting</a></h4> </body> </html>
...any ideas?
specifically the mail code is:
<?php $message="Thanks for registering on our website! Open a new window and go to http://www.slicksilver.uni.cc/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks."; $to = &$email; $subject = 'Validate This Email'; $headers = 'From: *******' . "\r\n" . 'Reply-To: *************' . "\r\n" . //This statement helps out with spam filters 'X-Mailer: PHP/' . phpversion(); //Send the email mail($to, $subject, $message, $headers); ?>
I have been testing it out in GMail because in my opinion it is the most leniant. thanks for any help possible.
.-=<!--HoTDaWg--!>=-.
-
any ideas?
-
just to double check you can simply do:
<?php mysql_query($sql,$connection); //rather than $results = mysql_query($sql,$connection); ?>
at the same time, a user on the php manual wrote this under comments regarding mysql_query:
It says in the manual:
The query string should not end with a semicolon.
However, I read somewhere that it is good practice to add a semicolon at the end of your query, and that it increases security against SQL-injection attacks. Therefore I have issued a requirement that all my developers end queries with semicolons.
So far, PHP & MySQL have happily accepted those queries, with only one exception:
If you use more then one query in the same call to mysql_query, MySQL sometimes only executes the first query and fails on the others.
so, should i end my mysql_queries with a ; or should i not ??? is there some sort of alternate method.
thanks for any help possible,
.-=!HoTDaWg!=-.
-
<?php $query = "INSERT INTO repository VALUES ('".$link."')"; mysql_query($query,$yourlinktoyourconnection) or die(mysql_error()); ?>
- here is the proper format in my opinion
- you can not echo anything since insert will insert, to echo you will need to use the SELECT statement:)
- heres a good tutorial on the select statement http://www.php-mysql-tutorial.com/php-mysql-select.php
-
yea, u probably will need some javascript/css in there. i doubt ull need ajax but then again i never learnt it lol. check out an example of what you want here:
http://www.firecold.com/submit.php
view source it and im sure that can help you:)
-
in my opinion
'X-Mailer: PHP/' . phpversion();
is the most essential line. it helps to bypass filters in most email providers. also, in my experience it helps if you give a real email addresses under the headers, not just variables; think of it as if you are talking to a person. the more in-depth and honest you are the more likely the email will go throughh. at the same time, try not to send html mails:P.
theres more but i just got up lol and i gotta go look for a job so i gotta fly
peace homies,
HoTDaWg
-
Ok.. I confess that I'm a newbie with respect to PHP..
I your code, let's say I open up the webpage google.ca.. The page title is google... in the code you presented, would the variable $title = google? If this is the case, then yes this is what I'm after..
Thanks.
no, understand this, PHP is not like html it is known for doin the background work. HTML is still used to edit <title> and make tables etc.
-
woah
amazing clone man!
lol
HoTDaWg
-
anyone?
-
i know exactly what your asking bro, i freight of this problem as well once my website is put in to play.
well there is always the sacred seterrorhandler function.
check it out @:http://ca3.php.net/set_error_handler
best of luck, it can be very tricky (well for me at least),
HoTDaWg
-
it would be easier if u made the schedule itself in php, then when it comes to printing; you can create a page called print.php which gets the variables you want to print, echos it, and then prints it.
HoTDaWg
-
W3C is probably the best out there. I mean they do set the standards for the whole internet...
hes right lol take a look at googles rating:
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.google.ca
-
alright,
so, this script was functioning fully until i added in the following code. It works fine when i call upon it.
<?php if(!empty($username)&&($email)){ $check1= "SELECT username FROM users WHERE username='".$username."'"; $checkit1= mysql_query($check1,$c0nn); if(mysql_num_rows($checkit1) > 0 ){ $arrErrors['username_already_exists'] = 'The Username you Chose is Already Being used by another person.'; } $check2= "SELECT email FROM users WHERE email='".$email."'"; $checkit2= mysql_query($check2,$c0nn); if(mysql_num_rows($checkit2) > 0 ){ $arrErrors['email_already_exists'] = 'The E-mail you Entered Already Exists in our Records.'; } } ?>
The success message is echoed, but the email is not sent. This is the registration form:
<?php /*Begin the long awaited profile.php. Copright (C) March 12th 2007. comon man i spent a long time on this:P*/ //It Begins. $c0nn = mysql_connect("localhost","*****","********")or die(mysql_error()); mysql_select_db("********"); define('******',true); include "functions.php"; //Get it, get it now. $arrErrors = array(); if(isset($_POST['submit'])){ $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $submit = $_POST['submit']; $ip= $_SERVER['REMOTE_ADDR']; $date = date('d m Y @ h:i:s A'); //Empty?! I THINK NOT! if(empty($username)){ $arrErrors['username_left_blank'] = 'The Username Field was left blank'; } if(empty($password)){ $arrErrors['password_left_blank'] = 'The Pasword Field was left blank'; } if(empty($email)){ $arrErrors['email_left_blank'] = 'The E-Mail Field was left blank'; } //Too Long?! I THINK NOT! if(strlen($username) > 12){ $arrErrors['user_too_long'] = 'The Username Field exeeds the limit of <b>12</b> characters'; } if(strlen($password) > 14){ $arrErrors['pass_too_long'] = 'The Password Field exeeds the limit of <b>14</b> characters'; } if(strlen($email) > 50){ $arrErrors['email_too_long'] = 'The Email Field exeeds the limit of <b>50</b> characters'; } //Invalid characters...grr... if (preg_match('|[^-_a-z\d]|i', $username)) { $arrErrors['user_invalid_charcters'] = 'The Username Field has (an) invalid character(s).'; } if (preg_match('|[^-_a-z\d]|i', $password)) { $arrErrors['pass_invalid_characters'] = 'The Password Field has (an) invalid character(s).'; } //Just a minute, dear $username = mysql_real_escape_string($username); $email = mysql_real_escape_string($email); //Check it if(!empty($username)&&($email)){ $check1= "SELECT username FROM users WHERE username='".$username."'"; $checkit1= mysql_query($check1,$c0nn); if(mysql_num_rows($checkit1) > 0 ){ $arrErrors['username_already_exists'] = 'The Username you Chose is Already Being used by another person.'; } $check2= "SELECT email FROM users WHERE email='".$email."'"; $checkit2= mysql_query($check2,$c0nn); if(mysql_num_rows($checkit2) > 0 ){ $arrErrors['email_already_exists'] = 'The E-mail you Entered Already Exists in our Records.'; } } //FINALLY! if(count($arrErrors) < 1){ //Secure the variables $password = mysql_real_escape_string($password); $email=strip_tags($email); $username=strip_tags($username); $password=strip_tags($password); $email=addslashes($email); $username=addslashes($username); $password=addslashes($password); //Create the display name $displayname =&$username; $username=strtolower($username); $displayname = mysql_real_escape_string($displayname); //final filter $password = md5($password); //Insert now $emailcode = rand(0,100000000); $status = "incomplete"; $sql = "INSERT INTO `users` (`id`,`displayname`,`username`,`password`, `email`,`usercode`,`status`,`date`,`ip`) VALUES (' ', '$displayname', '$username', '$password', '$email', ' ', '$status', '$date', '$ip')"; $result=mysql_query($sql,$c0nn); if($result){ mysql_close(); successmail(); echo "Your registration is almost complete, please check your email which you provided us with in order to verify your email address. If you do not recieve your email within the next 24 hours this is an error with your email service provider. Thank you for registrating!"; }else{ errormail(); echo "An unexpected error has occurred. Your registration was not complete."; } }else{ $strError = 'Please check the following and try again:<br>'; // Get each error and add it to the error string // as a list item. foreach ($arrErrors as $key => $value){ $strError .="<li><b>Error Type:</b>{$key} <b>Error message:</b> {$value}</li>"; } echo $strError; ?> <form name="hey" action="<?php echo $_SERVER[php_SELF];?>" method="POST"> <input type="text" maxlength="12" name="username" value="<?php echo $_POST['username']; ?>"><br> <input type="text" name="password" value="<?php echo $_POST['password']; ?>" maxlength="14"><br> <input type="text" maxlength="80" name="email" value="<?php echo $_POST['email']; ?>"><br> <input type="submit" name="submit" value="submit"></form> <?php } }else{ echo form(); } ?>
functions.php
<?php /* begin*/ if(!defined('*******')){ echo "You accessed this page incorrectly."; exit(); }else{ function form(){ $submit = $_GET['submit']; if(!isset($submit)){ echo '<form name="hey" action="'.$_SERVER[php_SELF].'" method="POST"><input type="text" maxlength="12" name="username" value=""><br><input type="text" name="password" value="" maxlength="50"><br><input type="text" maxlength="80" name="email" value=""><br><input type="submit" name="submit" value="submit">'; } } function successmail(){ $message="Thanks for registering on our website! Open a new window and go to http://www.mediacircus.yurx.com/validateme/index.php?email=$email&emailcode=$emailcode&mode=verify to complete your registration. thanks."; $to = &$email; $subject = 'Validate Yourself'; $headers = 'From: *******@****.com' . "\r\n" . 'Reply-To: *******@****.com' . "\r\n" . //This statement helps out with spam filters 'X-Mailer: PHP/' . phpversion(); //Send the email mail($to, $subject, $message, $headers); } function errormail(){ $browser = $_SERVER['HTTP_USER_AGENT']; $to = '*******@****.com'; $message = "Userip: $ip Date: $date Username: $username Password: $password Email: $email Browser: $browser"; $subject = "Registration Form Error"; $headers = 'From: *******@****.com' . "\r\n" . 'Reply-To: *******@****.com' . "\r\n" . //This statement helps out with spam filters 'X-Mailer: PHP/' . phpversion(); //Send the email mail($to, $subject, $message,$headers); } } ?>
to sum up, in the registration form itself, the success message is echoed. the email however (which is in functions.php) does not send.
thanks,
HoTDaWg
-
So much for knowing what it is you are trying to achieve vs what the code is doing. *shrugs*
im sorry aebstract, this code is part of a registration form im making, it checks in the database if the email or username is already in the database.
thanks for your help guys but i now my whole registration form is messed up grr... lol brb in 20 min while i ATTEMPT to figure it out myself :S
thanks
HoTDaWg
-
<?php if(!empty($username)&&($email)){ $check1= "SELECT username FROM users WHERE username='".$username."'"; $sql1= mysql_query($check1,$c0nn); if(mysql_num_rows($sql1) > 0 ){ $arrErrors['username_already_exists'] = 'The Username you Chose is Already Being used by another person.'; } $check2= "SELECT email FROM users WHERE email='".$email."'"; $sql12= mysql_query($sql2,$c0nn); if(mysql_num_rows($sql2) > 0 ){ $arrErrors['email_already_exists'] = 'The E-mail you Entered Already Exists in our Records.'; } } ?>
i am still getting the error message:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mediacir/public_html/validateme/submit.php on line 57
:s wonder whats happening
HoTDaWg
-
what is wrong with this code...its been driving me NUTS!
<?php if(!empty($username)&&($email)){ $check1= "SELECT username FROM users WHERE username='".$username."'"; $sql1= mysql_query($check1,$c0nn); if(mysql_num_rows($check1) > 0 ){ $arrErrors['username_already_exists'] = 'The Username you Chose is Already Being used by another person.'; } $check2= "SELECT email FROM users WHERE email='".$email."'"; $sql1= mysql_query($check2,$c0nn); if(mysql_num_rows($check2) > 0 ){ $arrErrors['email_already_exists'] = 'The E-mail you Entered Already Exists in our Records.'; } } ?>
i keep on getting the following error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mediacir/public_html/validateme/submit.php on line 52 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mediacir/public_html/validateme/submit.php on line 57
thanks
HoTDaWg
-
if you dont mind frost110 could you supply that for me? Thank you all, and there is no rush frost.
topic solved,
HoTDaWg
-
<?php include("classes/core.inc.php"); $obj = new core; session_start(); include_once("classes/core.inc.php"); //why are you including the same thing twice? meh if(session_is_registered('user')) { //this will automatically redirect the user, giving them the option to see something could be a security risk header(Location:http://www.domain.com/nos-potret/testcop-4.1.php?album=216&page=1); }else{ ?> Log in form <?php } ?>
this should work. never mind stick with frosts THAT works. could somone please delete this post? thanks and sorry
HoTDaWg
-
on websites such as firecold.com or even forums; how is that each user kind of has their own page on the site. For example, if i was to sign up as the username hotdawg on a forum, how is it that when someone views my profile the address is:
http://www.example.com/profiles/hotdawg
rather than
http://www.example.com/members.php?username=hotdawg
or even
http://www.example.com/profiles/?username=hotdawg
How do you do that? is a separate page created for the user when they register?
any information on this subject would be very useful
HoTDaWg
-
thankk yoooouuuuuuu i have been lookin for so long.
-
chagned the code but still its showing a blank page ???
<?php function form(){ $submit = $_GET['submit']; if(!isset($submit)){ echo '<form name="hey" action="'.$_SERVER[php_SELF].'"><input type="text" maxlength="12" name="username" value=""><br><input type="text" name="password" value="" maxlength="50"><br><input type="text" maxlength="80" name="email" value=""><br><input type="submit" name="submit" value="submit"></form>'; } } //It Begins. $arrErrors = array(); $conn = mysql_pconnect("localhost","****","*******"); mysql_select_db("*********"); //Get it, get it now. if(isset($_POST['submit'])){ $username = $_GET['username']; $password = $_GET['password']; $email = $_GET['email']; $submit = $_GET['submit']; $ip = GetHostByName($REMOTE_ADDR); $date = date('d m Y @ h:i:s A'); //Empty?! I THINK NOT! if(empty($username)){ $arrErrors['error'] = array('type'=>'empty', 'description'=>"The Username Field has invalid characters."); } if(empty($password)){ $arrErrors['error'] = array('type'=>'empty', 'description'=>"The Pasword Field has invalid characters."); } if(empty($email)){ $arrErrors['error'] = array('type'=>'empty', 'description'=>"The E-Mail Field has invalid characters."); } //Too Long?! I THINK NOT! if(strlen($username) > 12){ $arrErrors['error'] = array('type'=>'toolong', 'description'=>"The Username Field exeeds the limit of <b>12</b> characters"); } if(strlen($password) > 14){ $arrErrors['error'] = array('type'=>'toolong', 'description'=>"The Password Field exeeds the limit of <b>14</b> characters"); } if(strlen($email) > 50){ $arrErrors['error'] = array('type'=>'toolong', 'description'=>"The Email Field exeeds the limit of <b>50</b> characters"); } //Invalid characters...grr... if (preg_match('|[^a-z\d]|i', $username)) { $arrErrors['error'] = array('type'=>'invalidchars', 'description'=>"The Username Field has invalid characters."); } if (preg_match('|[^a-z\d]|i', $password)) { $arrErrors['error'] = array('type'=>'invalidchars', 'description'=>"The Password Field has invalid characters."); } //FINALLY! if(count($arrErrors) < 0){ //Secure the variables $email=strip_tags($email); $username=strip_tags($username); $password=strip_tags($password); $email=addslashes($email); $username=addslashes($username); $password=addslashes($password); //Create the display name $displayname =&$username; $username=strtolower($username); //final filter $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $displayname = mysql_real_escape_string($displayname); $email = mysql_real_escape_string($email); $password = md5($password); echo "done"; }else{ $strError = '<div border="0"><p>Please check the following and try again:</p><ul>'; // Get each error and add it to the error string // as a list item. foreach ($arrErrors as $key=>$value){ print "<pre>"; print_r($arrErrors); print "</pre>"; } $strError .= '</ul></div>'; echo $strError; } }else{ echo form(); } ?>
-
source for examplescript.php
=============
PHP code here |
______________
Html undeneath |
=============
or even all the code is done in php thanks .tpl (.template) files :S it really depends on how much experience u got under the belt...lol under the belt...dirty lol.
-
like, i am introducing the error message like this:
<?php $arrErrors['error'] = array('type'=>'invalidchars', 'description'=>"The Password Field has invalid characters."); ?>
and im asking PHP to display the errors like this:
<?php foreach ($arrErrors as $key=>$value){ $strError .= "<li>{$arrErrors['error']}</li>"; } $strError .= '</ul></div>'; echo $strError; } ?>
what is the correct way to do this?
-
hey, i hate to steal your thunder but is there a name for the -> function i googled it but nothing came up. I see those everywhere and they seem to make code a lot cleaner. i wish i could help, but i probably got a couple more years till i can make something half as good as that.
HotDaWg
basic function, weird behaviour
in PHP Coding Help
Posted
Take a look at this:
its weird, i immedietely get the following error:
thanks for any help possible,
HoTDaWg