Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. just check the ones you need to check if ($_POST['formfield1'] == "") { echo "Form Field 1 was left blank"; } and so forth, or you can put them in a variable and repeat them back or you can exit the script, or however you want to do it.
  2. yes, very easy actually just have the drop down and have different choices, select the variable $message to different things, then when the mail is sent, message will be different depending on what was set to the variable.
  3. wait, you have to stop forgetting <?php ?> that php is very important, or it won't work with all php settings. so here is what you should have know with what I gave you. [code]<!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> <title>form.php</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php if (isset($submit)) { $connect = mysql_connect('localhost', "???????", "???????") or die ('Could Not Connect: ' . mysql_error()); echo '<b>Step 1 :</b> Connected Successfully! <br>'; $db = 'mydatabase'; mysql_select_db($db) or die('Could Not Select Database ('.$db.') Because of: '.mysql_error()); echo '<b>Step 2:</b> Connection to ('.$db.') successful!<BR>'; $textfield = $_POST['firstname']; $textfield2 = $_POST['surname']; // for not until you can get to where you can pass them straight into, you have to understand how the queries work first. name which has 3 fields : ID, First & Second $insert = "INSERT INTO name (first, second) VALUES ('$textfield', '$textfield2')"; if (mysql_query($insert)) { echo "Custom message thanking the person for putting in the data"; $controller = true; } // close if query mysql_close($connect); } // close isset ?> <?php if ($controller != true) { ?> <form name="form1" id="form1" method="post" action="form.php">        <p>First Name     <input type="text" name="firstname" /> </p>   <p>Surname     <input type="text" name="surname" /> </p>   <p>     <input type="submit" name="Submit" value="Submit" />   </p> </form> <?php } ?> </body> </html>[/code] go through every current script you have you have opening and closing tags <? ?> change those opening tags, all of them too <?php and let me know if you need any more help with anything else
  4. ah yes, good advice, here is what you would do, to get it to do that. [code]<!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> <title>form.php</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <? if (isset($submit)) { $connect = mysql_connect('localhost', "???????", "???????") or die ('Could Not Connect: ' . mysql_error()); echo '<b>Step 1 :</b> Connected Successfully! <br>'; $db = 'mydatabase'; mysql_select_db($db) or die('Could Not Select Database ('.$db.') Because of: '.mysql_error()); echo '<b>Step 2:</b> Connection to ('.$db.') successful!<BR>'; $textfield = $_POST['firstname']; $textfield2 = $_POST['surname']; // for not until you can get to where you can pass them straight into, you have to understand how the queries work first. name which has 3 fields : ID, First & Second $insert = "INSERT INTO name (first, second) VALUES ('$textfield', '$textfield2')"; if (mysql_query($insert)) { echo "Custom message thanking the person for putting in the data"; $controller = true; } // close if query mysql_close($connect); } // close isset ?> <?php if ($controller != true) { ?> <form name="form1" id="form1" method="post" action="form.php">        <p>First Name     <input type="text" name="firstname" /> </p>   <p>Surname     <input type="text" name="surname" /> </p>   <p>     <input type="submit" name="Submit" value="Submit" />   </p> </form> <?php } ?> </body> </html>[/code] That should be it, what that will do is, thank them for putting in the data, and make the form disappear when they enter the data.
  5. The bottom line is that it works, my script was the same thing your trying to do, but to help you learn,a nd you doubled the benefit from, what you are wanting, the bottom line is 1. Does it do what you wanted. 2. You created it yourself you have created your first custom script I would guess unless you have done this before.  Congratulations, if you need anything else feel free to post, but you sometimes have to give me time, because phpfreaks doesn't always email notifications, so I sometimes have to check manually, sorry I didn't get back to it sooner, congratulations.
  6. Ah perfect, I will use that in all my websites from now on, that I do with that company, I am going to sit down with teh company for awhile too, and explain to them the dangers of this, and tell them that they need to change it.
  7. I treid that one, and this time it gave me an interal server error 500, any advice?
  8. I am going to fix that, with the php thing that he showed me for all my clients, and call them, and tell them they have to figure out a way to fix that, I have asked other developers, and that means it's misconfigured.
  9. I tried that but for some reason it didn't work, any more advice on how to stop it from displaying.
  10. ok how would I put something in htaccess to stop that file from getting access, he said it was because they allow everyone on the server access to there own php.ini file, because of that, ti does that, I can do something with htaccess, anya dvice on what?
  11. I called the hosting company, and he checked his site that is hosted by bluehost he said it wasdoing the same thing and that is strange, he is checking in on it now.
  12. Well other sites under that hosting has it either, is there a specific setting I need to set up to be able to do that, I never thought about that, I am scouring sites now trying to find other ones, I have found a few but not as many as I would have thought?
  13. actually it doesn't happen on all sites, phpfreaks doesn't and, msn doesn't but all of my sites do, and some others, how do I fix this, or is this not an issue, or what
  14. i just tried this and it works When I go to a website www.domainname.com/php.ini it pulls up the ini file for the site, isn't that a severe security risk, they immediately get to see all information about php's settings,  your version number, ALL the settings, and this is the same way with all sites, almost all sites have it to where it can be easily downloaded, is this a security issue at all, if so why is it set to be able to do that.
  15. Thanks for the advice, I appreciate and for the author of the post, if you needed any more help feel free to ask.
  16. Your right and I apologize, that is something to do when you know the difference, when I teach I will teach the correct way, and allow them to branch off if they choose to do so later on.
  17. There are always things that can be done one way or another for instance with variables, when extrapolating you can just put $variable or you can put {$variable} I use to use $variable, but instead decided to start using {$variable} but with query's I use the short way because I type queries so much I have be able to do them, quickly.  But I suppose it would be a good habit to get into doing it like that from the very beginning.
  18. yes it can be, but it doesn't have to be typed out that way, that would be the way that it's supposed to be done but the other way works as well, thanks for pointing that out.
  19. [code]<? if (isset($formsubmit)) { $connect = mysql_connect("localhost", "username", "password"); $selectdb = mysql_select_db("databasename"); if (!connect || !selectdb) { echo "There was an error connecting to, or select the database"; echo mysql_error(); // remove this after you get it working properly } $textfield = $_POST['firstname']; $textfield2 = $_POST['surname']; $insert = "INSERT INTO name(first, second) VALUES $textfield, $textfield2;"; if ($query = mysql_query($insert)) { echo "The data was inserted into the database correctly"; }else { echo mysql_error(); // take this out when it starts working. echo "There was a problem inserting the data into the database";   } } ?> <form name="form1" id="form1" method="post" action="page.php">        <p>First Name     <input type="text" name="firstname" /> </p>   <p>Surname     <input type="text" name="surname" /> </p>   <p>     <input type="submit" name="formsubmit" value="Submit" />   </p> </form>[/code] I had a few errors, I was in a hurry, that should work, don't forget to replace the form part, where it says action, to the name of the page that you are working on, whatever page the script is on, needs to be set to that page name.
  20. [code]<? if (isset($formsubmit)) { $connect = mysql_connect("localhost", "username", "password") $selectdb = mysql_select_db("databasename"); if (!connect || !selectdb) { echo "There was an error connecting to, or select the database"; echo mysql_error(); // remove this after you get it working properly } $textfield = $_POST['firstname']; $textfield2 = $_POST['surname']; $insert = "INSERT INTO name(first, second) VALUES $textfield, $textfield2;"; if ($query = mysql_query($insert)) { echo "The data was inserted into the database correctly"; }else { echo mysql_error(); // take this out when it starts working. echo "There was a problem inserting the data into the database";   } } ?> <form name="form1" id="form1" method="post" action="">        <p>First Name     <input type="text" name="firstname" /> </p>   <p>Surname     <input type="text" name="surname" /> </p>   <p>     <input type="submit" name="formsubmit" value="Submit" />   </p> </form>[/code] That should fix it, but if it works on your other script you shouldn't need it, tell me if you need anything else?
  21. ok, first of all change your username and password, forget the variable part, and put the information straight into the query, just for practice it saves coding room, as well you never should put your username and password in a post put #### #### for hte username and password or something similar to keep people from seeing them, you have to change your password, and username now or someone could get into your database, try this out. [code]<? if (isset($formsubmit) { $connect = mysql_connect("localhost", "username", "password") $selectdb = mysql_select_db("databasename"); if (!connect || !selectdb) { echo "There was an error connecting to, or select the database"; echo mysql_error(); // remove this after you get it working properly } $textfield = $_POST['firstname']; $textfield2 = $_POST['surname']; $insert = "INSERT INTO name(first, second) VALUES $textfield, $textfield2;"; if ($query = mysql_query($insert)) { echo "The data was inserted into the database correctly"; }else { echo mysql_error(); // take this out when it starts working. echo "There was a problem inserting the data into the database";   } } ?> <form name="form1" id="form1" method="post" action="">        <p>First Name     <input type="text" name="firstname" /> </p>   <p>Surname     <input type="text" name="surname" /> </p>   <p>     <input type="submit" name="formsubmit" value="Submit" />   </p> </form>[/code] I made some modifications and where you had [code]mysql_close($connect);[/code] Those closes the connection you had closed the connection before the query. Read over it carefully, copy and paste the entire code, copy the EXACT output, and let me know what it says. I don't think I missed anything there but I was in a little bit of a rush, copy and paste the exact output and let me know how it works.
  22. [code]$textfield = $_POST['textfield']; $textfield2 = $_POST['textfield2']; // for not until you can get to where you can pass them straight into, you have to understand how the queries work first. name which has 3 fields : ID, First & Second $insert = "INSERT INTO name (first, second) VALUES $textfield, $textfield2;"; mysql_query($insert);[/code] Play with that a few hours, see what you can do, if it doesn't work try to debug it, through trial and error you will learn, that should work directly but look up each part on your own, play with that some, and get a good feel for that.
  23. I can create the pages for custom error messages, but I don't know how to set the lines in htaccess, any advice?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.