Ninjakreborn
Members-
Posts
3,922 -
Joined
-
Last visited
Everything posted by Ninjakreborn
-
So with me trying to insert it into my current script it should look something roughly like this [code]if($management == true) { $query = "SELECT * from signoninfo WHERE name = '$_POST['name']' AND email = '$_POST['email']'"; $result = mysql_query($query) $matches = @mysql_numrows($result); if ($matches == 1) { $inserter = "INSERT INTO signoninfo (name, email) VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['email']) . "')"; if(mysql_query($inserter)){ $management = true; }else { echo "There was some sort of error interacting with the database.<br />"; echo "Your information was not inserted into it for some unknown reason.<br />"; echo "Please contact us at info@theyellowpagesnetwork.com and notify us of this<br />"; echo "we thank you for your patience!<br />"; $management = false; } } } [/code] like that, in my current script, if this is how it goes, then how does $matches == 1, I am sorry for all the questions but my php/mysql knowledge has tripled this past week, and now I keep running into barriers, I am trying to sort through it and learn at the same time as I go along. Thanks
-
[code]$query = "SELECT * from tablename WHERE something = '$somevalue'"; $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); $matches = @mysql_numrows($result); if ($matches == 1) { // this already exists } else { // do something different }[/code] This is what my question is here, I saw this before, I know the $query is going to do something but how would I use it with my 2 values, I am still learning a lot here, but this is something I will need a little boost with, I need to fit it into my script but I can work that out for the most part what i need help is, how do I test the 2 values I have in my script, with them being $_POST[''] form fields and all, I just don't understand what this is doing.
-
How do I check a database to see if something exists, I have my whole script worked out, it works perfectly but I don't know how to get it to where it checks the database first. [code]<?php // This is a page that holds 2 different scripts, this completely controls the results coming from the form on signup.php, the purpose of these 2 scripts is to detect which button was pressed, if subscribe was pressed the top set of scripts under the giant if statement run. If unsubscribe is pressed then the if statement corresponding to unsubscribe is ran. // Begin subscribe script if (isset($_POST['subscribe'])) { // tests if subscribe was clicked on, on the form page $errorhandler = ""; // This will control holding error information $management = true; // Gives me full control over when the script runs and stops $regex = "^[A-Za-z0-9\._-]+@([A-Za-z0-9][A-Za-z0-9-]{1,62})(\.[A-Za-z][A-Za-z0-9-]{1,62})+$"; // regex variables has a regex value initialized into it, this allows me to quickly run // the regex functions through the email field to test it's format. It makes sure it // contacts an at symbol, and a period, and in the proper places. if ($_POST['name'] == "") { // checks if name is empty, and puts error info into string $errorhandler .= "The Name Field was not filled in correctly<br />"; } if ($_POST['email'] == "") { // checks if email is blank $errorhandler .= "The Email Field was not filled in correctly<br />"; } if ($_POST['email'] != $_POST['verifyemail']) { //checks if email fields match $errorhandler .= "The email address DO NOT match<br />"; } if (!ereg("$regex", $_POST['email'])) { //tests emails format with regex variable above $errorhandler .= "The email address is improperly formatted<br />"; } if ($errorhandler != "") { //This tests the error handler to see if it has recieved print "$errorhandler"; //any information or not, if it has then it prints the errors $management = false; // and changes management to false, which prevents other parts of } // the script from running later on down the road if($management == true) {// This is were management first comes into play. $connect = mysql_connect("localhost", "####", "######"); //connects to db $select = mysql_select_db("######"); // selects db if (!$connect || !$select){ //Tests the connection and sellection echo "There was a problem interacting with the database please contact us at "; echo "info@theyellowpagesnetwork.com"; // If it doesn't connect or select it returns $management = false; //errors and changes the management to prevent action during other } //parts of the script } // It gets closed 2 times, once for the first if, a second for the other if statement if($management == true) { $inserter = "INSERT INTO signoninfo (name, email) VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['email']) . "')"; if(mysql_query($inserter)){ $management = true; }else { echo "There was some sort of error interacting with the database.<br />"; echo "Your information was not inserted into it for some unknown reason.<br />"; echo "Please contact us at info@theyellowpagesnetwork.com and notify us of this<br />"; echo "we thank you for your patience!<br />"; $management = false; } } if($management == true) { // start major if mail system construct $mailmanager = true; // sets another manager to manage all email scripts if($mailmanager == true) { //tests for the mail manager script $to = "{$_POST['email']}"; // sets where the email goes to $subject = "Funny Email Forwards News Letter Notification"; // sets the subject $message = " This is to notify {$_POST['name']} that you have signed up to "; $message .= "Funny Email Forwards at {$_POST['email']}. You should be "; $message .= "Recieving an email within the next hour that will give you a full list "; $message .= "of all funny related entries from our database. "; $message .= "If you do not recieve the other email within 24 hours please contact "; $message .= "info@theyellowpagesnetwork.com and we will manually send you one."; // everything under the message variables sets the contents for the mail if(mail($to, $subject, $message)){ // opens up another if construct for email to user echo "Thank you for signing up to the news letter<br />"; // confirmation message echo "You should recieve a confirmation and first letter within 3 hours"; //same here $mailmanager = true; // sets mail manager for use with script below this one }else { // if it doesn't mail then instead it does this echo "There was some sort of problem sending you a confirmation email"; // error message echo "this problem is direcly relating to sending you a confirmation email"; //same echo "I apologize for this error, please contact us at info@theyellowpagesnetwork.com"; echo "and we will manually get the process started for you, thanks for your"; //same echo "time and patience"; // same $mailmanager = false; // sets mail manager to false to discontinue the script later } //closes the else construct above }// closes the bigger if construct containing mail function if($mailmanager = true){ // starts admin mail section $to = "businessman332211@hotmail.com"; // sets email to send to $subject = "Funny Email Forwards Subscription"; // sets subject $message = "This is to inform you that {$_POST['name']} has signed up to the "; $message .= "newsletter under {$_POST['email']} at Funny Email Forwards.com."; // sets email message mail($to, $subject, $message); // send an email to admin } // final if, encloses all coding in admin mail section } // closes entire mail related script } // closes entire section pertaining to subscribe // End Subscribe Script //Begin Unsubscribe Script // The script below here is used if someone clicked on unsubscribe on the form. ?>[/code] someone please help me with this, I learnt a lot but I still ran into this problem, i have a few ideas but none of them worked. I wish they just allower LIMIT 1 to work in this situation, it would be a whole lot easier, than forcing another way. Any advice thanks.
-
I know, I like the idea though, I can create pawns while programming, that have power.
-
FINALLY I found the problem I had finally gotten it, what was happening was I was testing it, but when the script got there it testing to see if it was true, IF IT wasn't true then it popped up that message in the else statement so I changed that part to this. [code]<?php if (isset($_POST['subscribe'])) { $errorhandler = ""; // This will control holding error information $management = true; // Gives me full control over when the script runs and stops $regex = "^[A-Za-z0-9\._-]+@([A-Za-z0-9][A-Za-z0-9-]{1,62})(\.[A-Za-z][A-Za-z0-9-]{1,62})+$"; // regex variables has a regex value initialized into it, this allows me to quickly run // the regex functions through the email field to test it's format. It makes sure it // contacts an at symbol, and a period, and in the proper places. if ($_POST['name'] == "") { // checks if name is empty, and puts error info into string $errorhandler .= "The Name Field was not filled in correctly<br />"; } if ($_POST['email'] == "") { // checks if email is blank $errorhandler .= "The Email Field was not filled in correctly<br />"; } if ($_POST['email'] != $_POST['verifyemail']) { //checks if email fields match $errorhandler .= "The email address DO NOT match<br />"; } if (!ereg("$regex", $_POST['email'])) { //tests emails format with regex variable above $errorhandler .= "The email address is improperly formatted<br />"; } if ($errorhandler != "") { //This tests the error handler to see if it has recieved print "$errorhandler"; //a string information if so it passes the information below. $management = false; } if($management == true) {// This is were management first comes into play. $connect = mysql_connect("localhost", "####", "#####"); $select = mysql_select_db("#####"); if (!$connect || !$select){ echo "There was a problem interacting with the database please contact us at "; echo "info@theyellowpagesnetwork.com"; $management = false; } } if($management == true) { echo "everything seemed to work all right"; } } ?>[/code] and it worked, I just have to think ahead from now on when organizing me if else statements, I was unaware I could create an if statement, with others inside of it, to that level, I am starting to understand control structures more and more, thanks for all the help I really appreciate it.
-
could it be something wrong with my computer, internet, or server:S
-
here let me show you what I mean. For instance, I am back to my old script with true or false. Here is what I want, I start the script off with $management = true; That makes management true right at the start. if it encounters an error then $management = false; it changes the script. now when it gets down to that section it should test whether $management is true or false if it's true (meaning encountered no errors so far) then it should try to connect to the database, if it can't then return the error problem while interacting with the database. If it is false, meaning that an error was encounter, see it starts as true, if it hits an error it changes to false, with it being false from an error, when the script tests, and sees it's false, it still runs the script anyway so what it is telling me is $management = true at the beginning later on down every error it hits, when it gets to the error handler, it changes it to false if it detected any errors in validation. If $management is then false, how does it still run a script saying if management is true. Look at the script again and you will see what I mean, I intended to test for validation, and change to false if some was encountered, to prevent the rest of the script from running, but it's not working right.
-
Uhh what the hell is going on today, I tried even your script, word for word, all the way down to the letter, copied and pasted into a test.php, ran my action through it, when it ran the script it messed up the same thing. What is going on with this, is there something were both missing, I tried your script as a test, and it still ran down the whole thing, when I click subscribe it returned all the error messages, and still gave the error message could not interact with database, what's going on with this. Is my computer possessed by anti-php demons or something. This is a programmers nightmare, I really am in hell aren't I. I thought programming was heaven, but I have crossed over into hell...
-
Youfound that problem it looks like, good eye.
-
I tried changing the managements with 0 and 1 instead of true false, but it still didn't work so I changed it back, does anyone at all see anything else wrong with this script, I tried that, when you said that I was thinking do variables double initialize for instance, do 2 trues make a false, and 2 false's make a true or something I didn't know. like if I have $management = true; Then go and do $management = false; $mangement = false; does that make it true or something, that is what's confusing me [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]
-
I have went through a thousand different ways to do this same script, my original idea was to come up with my own idea, I have asked for hundreds of peoples advice, and put it all together, tried things, didn't like them, I finally found a specific way I like, and what I know is wrong is the way I set up my if statements, as always I get confused with control structures, I have went over this script 1000 times, Ididn't want it trying to connect to a database, unless it passed all validation, I finally thought I had an idea with the management variable and it still didn't work, I like the way I did validation, I finally found something I like, that is fun programming, and allows "me" a good basis if I wanted to add new features, what I need help with now, is figuring out what is wrong with my control structure, if it encounters an error $management should change to false, and as long as it's false those if control structures down there shouldn't work, they should get to it, read if ($management == true){ do whatever } and it should say "ok since $management is currently false, then this part of the script isn't supposed to activate but what it's currently doing which is pissing me off, is I go to the site, if I don't fill in any fields and click submit, it should start going down the script. It should start off the script it gets down to the first line and checks name to see if it's blank, ok it is, so it should put something into the error handler string and change management to false, as it moves down the script it should check more errors. Then it gets to the error handler string, the script looks and asks is $errorhandler a string, if it has acquired any errors then it is indeed a screen and it runs the script, at that time it passes out all the errors, if this has happened, then Definitely management is currently false, so it should move further down the script, the script asks if management is true or not, if it's true then it should work the script if it's false then it knows not to do that, but EVEN THOUGH the damn thing is false, it still decides it wants to go against what I said, and run the script anyway, what's going on. because when I go to the site www.funnyemailforwards.com and I click on sign on and I click subscribe it gives me all the validation error messages, and the error message saying it couldn't interact with the database, it shouldn't even be trying to interact with the database,.
-
I don't know really, personal preference possibly, but I don't understand why it's not working, it has nothing to do with that part, It has something to do with the management variable, I just don't understand why it's not working, It shouldn't pass that control structure if $management == false; but it does, it still runs that part of the script for some reason.?? I can try that to make sure, but what I was told is that "" = null, so null means not existent, like not a string, not an array so if you do. $error[] = null; then it's still not an array, and $error[] = ""; is the same thing, but even changing that won't do anything with that part of the script, I can play with it, maybe come up with a way I like better for errorhandler but for now I have to figure out what's wrong with this script, any help would be appreciated.
-
sounds to me like your not pointing the includes to the right filepaths, make sure they match, it's telling you it can't find them.
-
[b]SOLVED[/b] Never have I felt so much anger towards one computer. At 3:30 in the morning I felt that I wanted to rip my monitor to pieces. Here is the question, and problem I have been facing. [code]<?php if (isset($_POST['subscribe'])) { $errorhandler = ""; // This will control holding error information $management = true; // Gives me full control over when the script runs and stops $regex = "^[A-Za-z0-9\._-]+@([A-Za-z0-9][A-Za-z0-9-]{1,62})(\.[A-Za-z][A-Za-z0-9-]{1,62})+$"; // regex variables has a regex value initialized into it, this allows me to quickly run // the regex functions through the email field to test it's format. It makes sure it // contacts an at symbol, and a period, and in the proper places. if ($_POST['name'] == "") { // checks if name is empty, and puts error info into string $errorhandler .= "The Name Field was not filled in correctly<br />"; $management = false; } if ($_POST['email'] == "") { // checks if email is blank $errorhandler .= "The Email Field was not filled in correctly<br />"; $management = false; } if ($_POST['email'] != $_POST['verifyemail']) { //checks if email fields match $errorhandler .= "The email address DO NOT match<br />"; $management = false; } if (!ereg("$regex", $_POST['email'])) { //tests emails format with regex variable above $errorhandler .= "The email address is improperly formatted<br />"; $management = false; } if (is_string($errorhandler)) { //This tests the error handler to see if it has recieved print "$errorhandler"; //a string information if so it passes the information below. $management = false; } if($management == true) {// This is were management first comes into play. $connect = mysql_connect("localhost", "#####", "######"); $select = mysql_select_db("#######"); }else { echo "There was a problem interacting with the database, please contact us at"; echo "info@theyellowpagesnetwork.com"; $management = false; } if($management == true) { echo "everything seemed to work all right"; } } ?>[/code] Ok what it's doing is doing all the validation, popping out the error, and still popping out There was a problem interacting with the database, whatever. What I don't get is I set a variable at the beginning $management = true; and as I went down I changed it to $management = false; if it ran into an error, then down there I said as a test to make sure it was performing right Here I said this if(is_string($errorhandler)) THIS SHOULD NOT work unless an error was detected, so when an error is detected this works and kicks out the proper error messages, then below that I have another control structure that says if ($management == true) { then do whatever This is what is confusing me, this is not common sense, if the script runs into any type of error, it should change $management to false, so if it encountered an error, then when the script tests to see if managment is true it SHOULD NOT read that at all if there was an error occured, any help would be appreciated, thanks.
-
Hmm I will look into a few of these ideas, I want advice on something really good advice, I know I have heard some, but honestly what should I do, use brackets or not use brackets with my if/elseif statements, I am wanting to figure out something that is easy to read, pretty to look at, and effective enough to be easy for me to understand as I go.
-
hmm, I studied heredoc for awhile but never thought I would have a purpose for it, I will keep this in mind, and experiment with it, any other advice opinions, about any of this appreciated as well, thanks for the advice so far.
-
Ah that makes sense, I will keep that in mind from now on, thanks for the advice. any more passer byers offering advice is appreciated as well.
-
I need advice, is this good or with the sql should I use, OR DIE, if so how do I utilize that over what I already have. I need to be able to switch it, but don't know enough about sql yet, How do I switch the if-else statements to utilize OR DIE with the error printed instead. [code]<?php if (isset($_POST['subscribe'])) { $error = ""; if ($_POST['name'] == '') $error .= 'The name field was filled in incorrectly, please correct<br/>'; if ($_POST['email'] == '') $error .= 'The Email Field was filled in incorrectly, please correct.<br />'; if ($_POST['verifyemail'] != $_POST['email']) $error .= 'The email Fields Do Not match, please correct.<br />'; if ($error != "") echo $error; else { $connection = mysql_connect('shouldbeobvious', 'iknowiamnotgay', 'haveyoueverlostimportantpassword'); $selectdb = mysql_select_db('hahacantsay'); if(!$connection || !$selectdb) { echo 'Problem during database connection or selection'; echo mysql_error(); } else { $insert = "INSERT INTO crackheadtable (name, email) VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['email']) . "')"; if(!mysql_query($insert)) echo 'The information could not be inserted into the database'; else $name = $_POST['name']; $email = $_POST['email']; $to = 'businessman332211@hotmail.com'; $subject = 'Funny Email Forwards Sign up Notification'; $message = "This is a confirmation to inform you that"; $message .= "you have been signed up to the Funny Email Forwards"; $message .= "Newsletter. If you choose to unsubscribe please visit"; $message .= "The website again to unsubscribe."; $message = wordwrap($message); if(mail($to, $subject, $message)) echo "You have been subscribed successfully<br />"; else echo "There was an error sending an email"; } @mysql_close($connection); $to = "businessman332211@hotmail.com"; $subject = "Funny Email Forwards sign up"; $message = "This is a notification letting you know that {$name} has"; $message .= "signed up to the news letter using {$email}."; $message .= "notification is coming from Funny Email Forwards.com"; $message = wordwrap($message); mail($to, $subject, $message); } } ?>[/code]
-
bump- still need help if anyone has any answers to offer, thanks.
-
Ok so atleast hopefully he got the help he needed.
-
I will make sure I am thinking of waiting on teaming to, someone wants me to build something like mapquest [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] I have no idea how to set up a map program:S
-
if you want give me your host name, and I will call them and talk to them see if I can figure out some details, I am new at learnign the language, but I am working as security with a company now, on the side, and my MAIN study was security and performance, that is why I ask so much if you want, I can pour over your php.ini file and make sure they are at the secure default settings and check over the site to make sure it's all secure, and contact the host to get more information, I can probably do some to try and help make it more secure, it's worth an offer at least, let me know. I meant url of your hosting company by the way.
-
I am only 50 percent sure but I think that in sql select and from should be all caps. and member_messages doesn't have the variable symbol in front of it. Just some suggestions but I could be wrong.
-
a few possibilities. Try and put the exit function in side the bracket you want to close, and then start up a nother one, or you could try sleep, and unsleep instead, but I think that will be a different affect. The only other idea I had was, like people told me on here maybe you could keep a variable and start it as true at the top, and then don't use the variable at all then after the kill statemtn, you could say if whatever is true, then continue your code, but then again if kill ends the script I don't see how it will make it to the end. You could use or die I don't know if sql will work though when randomly thrown in throughout php, but it's worth a thought.
-
For one try [a href=\"http://www.sitestats.com\" target=\"_blank\"]Site Stats[/a] That might be something you will want to consider, other than that, I don't have a lot to offer other than some suggestions. 1. Possible have php pick up Ip address, browser version and model, and whatever else you can pick up and email it to a specific email address everytime they come, this could let you keep track of where they go. Or create a database, with lot of columns like ip address(this will be your main field and what you sort by). browser type browser version browser make javascript enabled(can be picked up with javascript, and passed via variables into php, then used as information). whether they have java enabled(have no idea) and check for some other stuff like what operating system then you can have a counter labeled visits, and if you want to get fancy 1 table for visits with 1 column for each web page. then when they enter it records a new number for that ip into the ip database, and you can tell how many time each ip address has visited each page, if you want to get even fancier maybe something to check and find out what order they went in, like have a control panel for yourself, where you can call the data from the database, and arrange it so that it appears based on ip, then IN ORDER what places they visited, maybe even record time and dates. Another thing you could do is pick a webhost with good stats. I use bluehost, but also there's isn't what I wanted. You could also learn to read the log and be able to tell more from reading it than you could from stat informaiton. Just some thoughts.