-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
ALL YOU HAVE TO DO IS TAKE OUT THAT ECHO LIKE I'VE SAID 3 TIMES!
-
The error shows on the client screen. Take out the echo and you will remove your problem
-
monkaur - you're missing the problem. I already told him about the error checking being missing and my code provided that for him already. His reall problem is why does his script NOT give him an error on his header call?
-
Your code is not what you sent me. Try this: <?php session_start(); // ALWAYS TURN ON ERROR CHECKING DURING DEVELOPMENT!!! error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); //*********************** $fnameErr = $lnameErr = $emailErr = $unameErr = $pwd1Err = $pwd2Err = ""; $fname = $lname = $email = $uname = $pwd1 = $pwd2 = ""; // turn off error indicator $errors = false; //***************************** // check if we have a POST or not. if ($_SERVER["REQUEST_METHOD"] <> "POST") { displaypage(); exit(); } else { // handle the inputs now. if (empty($_POST["fname"])) { // turn on error flag $errors = true; $fnameErr = "* First name is required"; } else { $fname = test_input($_POST["fname"]); if (!preg_match("/^[a-zA-Z]*$/",$fname)) { $errors = true; $fnameErr = "* Only letters are allowed"; } } if (empty($_POST["lname"])) { $lnameErr = "* Last name is required"; $errors = true; } else { $lname = test_input($_POST["lname"]); if (!preg_match("/^[a-zA-Z]*$/",$lname)) { $lnameErr = "* Only letters are allowed"; $errors = true; } } if (empty($_POST["email"])) { $emailErr = "* Email is required"; $errors = true; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "* Invalid email format"; $errors = true; } } if (empty($_POST["uname"])) { $unameErr = "* Username is required"; $errors = true; } else { $uname = test_input($_POST["uname"]); if (!preg_match("/^[a-zA-Z0-9]*$/",$uname)) { $unameErr = "* Only letters and numerals are allowed"; $errors = true; } } if (empty($_POST["pwd1"])) { $pwd1Err = "* Password is required"; $errors = true; } else { $pwd1 = test_input($_POST["pwd1"]); } if (empty($_POST["pwd2"])) { $pwd2Err = "* Password confirmation is required"; $errors = true; } else { $pwd2 = test_input($_POST["pwd2"]); if($pwd1 != $pwd2) { $pwd2Err = "* Passwords do not match"; $errors = true; } } // are there any errors? if ($errors == false) { $to = $_POST['email']; // this is your Email address $from = "verify@dfwit.co"; // this is the sender's Email address $fname = $_POST['fname']; $lname = $_POST['lname']; $subject = "Form submission"; $message = $fname . ":\n\n" . "Thank you for subscribing to DFW Information Technologies database services.\n\nYour login credentials are:\n\nUsername: ".$uname."\nPassword: ".$pwd1."\n\nPlease click the link below to proceed to Login screen:\n\nhttp:www.dfwit.co/index.html\n\n\n\nTech Support: techsupport@dfwit.co\nSales: sales@dfwit.co"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); echo "Mail Sent. Thank you " . $fname . ", we will contact you shortly."; header("Location: www.dfwit.co/index.html"); // I put this in but it won't redirect until the mail // sends...and that's sorta slow. } else { displaypage(); exit(); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } function displaypage() { global $fname,$fnameErr,$lname,$lnameErr,$email,$emailErr,$uname,$unameErr,$pwd1,$pwd1Err,$pwd2,$pwd2Err; $action = htmlentities($_SERVER['PHP_SELF']); $code=<<<heredocs <form method="post" action="$action"> <input type="text" name="fname" placeholder="First Name" value="$fname"> <span class="error">$fnameErr</span><br><br> <input type="text" name="lname" placeholder="Last Name" value="$lname"> <span class="error">$lnameErr</span><br><br> <input type="text" name="email" placeholder="E-mail Address" value="$email"> <span class="error">$emailErr</span><br><br> <input type="text" name="uname" placeholder="Username" value="$uname"> <span class="error">$unameErr</span><br><br> <input type="password" name="pwd1" placeholder="Password" value="$pwd1"> <span class="error">$pwd1Err</span><br><br> <input type="password" name="pwd2" placeholder="Confirm Password" value="$pwd2"> <span class="error">$pwd2Err</span><br><br> <input type="submit" value="Submit"> </button> </form> </body> </html> heredocs; echo $code; } Please run this - it gives me the error message every time. Of course you should have fixed that by now.
-
Ok - form looks ok. So - getting back to the error message you should be getting. With error checking turned on, I ran your 3 lines of code and I get the expected message. Why don't you? Either you are not getting to them, or the code you are posting is not what is running. Add some echos to the code and let's see what gets output before we get to the header line.
-
Having now extracted your code and re-formatted it to read it and deciphered it, could we see the actual input form code? Q1 - why does you email use the unsanitized input values in the email instead of the ones you bothered to clean? Q2 - Do you ever receive the email? PS - I've got 12+ years on you!
-
It does have try catch blocks. But you have written the kind of checks you neeed. You just forgot to check if you set any of them. Trick: Use an array and set a different index for each message if you have an error. Then if the array is not empty you have messages to echo. Then do a foreach loop on the array and echo out each message. Back to the previous question - what's wrong with those three lines? Not the header! Again: You can't output anything prior to a header call. You send the mail. You output your message. You (attempt to) send a header. WRONG!
-
Hmmm - seme to have lost my response. Trying again. Tip - Why not add those tests for empty to your test function and save a whole lot of coding? Plus - why do you bother to do all the testing and not handle any errors that you find? Kind of a waste of energy, no?
-
Programming is a very exact science. Therefore you need to be able to clearly read your own code in order to debug it. As I said above - you can't output anything prior to the header call. So - what's wrong with your code here: mail($to,$subject,$message,$headers); echo "Mail Sent. Thank you " . $fname . ", we will contact you shortly."; header("Location: www.dfwit.co/index.html");
-
And you aren't seeing an error message? The error is you cannot execute a header command once you have output something. Which you are doing right after your mail() call.
-
sign? sign=signature. Did you add those lines to the beginning of your php code? Could we see it?
-
If you would turn on php error checking (see my sign.) you would see the reason that you don't see anything. It's not the email holding you up. It is the error you are generating.
-
Your script should send the email and then continue on with its responsibilities, namely providing the user with some sort of response. What are you doing in your script now?
-
From the manual: domain The domain that the cookie is available to. Setting the domain to 'www.example.com' will make the cookie available in the www subdomain and higher subdomains. Cookies available to a lower domain, such as 'example.com' will be available to higher subdomains, such as 'www.example.com'. Older browsers still implementing the deprecated ยป RFC 2109 may require a leading . to match all subdomains. Not sure what this means 'higher subdomains'. I always think of a sub as 'lower'. IIRead this correctly it says that a cookie in www.xyz.com will be available in xyz.com as well.
-
I'm not sure but I think that www.xyz.com is the same as xyz.com. Somehow. The 'true' subdomains tho are different. Either way if you begin in a specific domain name and set some cookies in the root folder they will be there for any users of said domain. What else could you want? In what world would you need cross-referencing of them between apps running in different domains?
-
Yes I am. And I see now how confusing my answer was to you. IF I had bothered to check first I would have said that the \ in the 4th argument would ensure that your cookies would be in the correct place regardless of what domain name was in $site. The cookies will be in the domain root because of the \ although the absolute path of that location will be different depending upon the current $site/domain value.
-
Why don't you read the manual re: cookies? You do read the manual when you have questions first, don't you?
-
I think that a simple \ should work. It will represent the root folder of whatever the domain is pointing to, no?
-
It doesn't look like anything to me. Ancient deprecated html code too. Probably copied from somewhere. Oh, well....
-
One usually posts code here rather than provide a link to a possibly infected site. One also turns on error checking in their php to see any potential errors. See my signature.
-
Is this homework? NO help from me if it is. And if you are trying to learn, why not try to write your own code and actually LEARN something before copying somebody's object-oriented code?
-
How to get rid of .html file when echo out images from folder
ginerjm replied to IamTomCat's topic in PHP Coding Help
Also - this line is not what (I think) you intend it to be: $filetype = '*.html'; $dirname = substr('$filetype'); $dirname is going to contain exactly: $filetype It is NOT going to contain anything with *.html (or any part of it). Substr requires a start value and you left it out. If you had turned on error checking (As You Should in development) you would be seeing a warning. -
I'm sure that this: store a basic 20 slot 0 iteration makes a ton of sense to you. Not to me. My one comment on something that I do understand - you have a system that stores multiple pieces of the same discrete data item into one field? Well if it works it works, but it is certainly not a RDBMS. Every time you read something you have to break it down into useable values and when you store it you have to reverse that process. Horrible design.
-
Action field? If you have a submit button with an event action too, then yes, the event response will occur as well as the form submission.
-
Both what?