Jump to content

MainStWebGuy

Members
  • Posts

    59
  • Joined

  • Last visited

Everything posted by MainStWebGuy

  1. Dear all powerful and all knowing Jacques, I don't know much, as i'm a noob (stated earlier), so calm down lol. I appreciate your feedback and will look into alternatives. thank you hail, long live, blah blah
  2. I'm hoping to receive tips or hints as to why it might be failing. I, of course, try to fix any and all bugs before launch through multiple rounds of testing, but, as i'm sure you know, that doesn't always cover everything. I was hoping to add some code that will, in the event of the form not sending, at least get a clue as to where to start looking.
  3. Awesome info, and thanks mac_gyver - can you give me a simple code example (I'm a noob man ) would i just do something like .... ... $failedMessage .= $php_errormsg; $failedMessage .= $ErrorInfo; ... something like that?
  4. Thanks Ginerjm I haven't checked into phpmailer in a while, and now i'm wondering if my host already has it as an option for me... i'll check into it. I guess i was wondering if there was a way i can collect php error(s) and send them along in the email, just like how i can "echo" them to the screen while i'm developing to help catch random mistakes in my code. Thanks again! Jason
  5. Hello all, I have a couple of simple php mail forms i use on a couple sites for sending basic contact information in email form when submitted. The code is pretty simple, and i use an IF statement to check to be sure the email has been sent, and if it fails, I am notified by email: #send the email if(mail($to, $subject, $message, $headers)) { ... send confirmation message... } else { #notify webmaster mail($toWebmaster, $failedSubject, $failedMessage, $failedHeaders); } My question is... in the $failedMessage, is there a way i can include any error information on why the form might be failing? If so, how would i do something like that? Thanks in advance, Jason
  6. Hello all, I came across something that's got me stuck: According to phpinfo(), my loaded phpp config file is in c:\Program Files\PHP\php.ini which is cool. Also in phpinfo() it says that my file_uploads are off. I wanted to turn them on so i went to the php.ini located in c:\Program Files\PHP\php.ini and fif a Ctrl+F for "file_uploads." The weird thing is that the php.ini shows that uploads are turned on. I did a search for any other php.ini files on the machine but can't find any more. Any ideas of how this could be happening? PS - file uploads are not currently working.
  7. AH HA! like i said... i am mildly retarded today... i'm going to go smack myself in the face, then move the variables inside the if statement that checks if submit was pushed... THANKS! Jason
  8. Hey guys, sorry to bother, but i'm brain dead today. I have a very simple script that i can't seem to get working. I am just generating two random numbers and asking the user to input the answer (spam check thingy), but i can't seem to get it going... here's what i'm using: <?php $a = rand(1, 10); $b = rand(1, 10); $c = $a + $b; ?> <p>Solve the problem to prove you're human:</p> <?php if(isset($_POST['submit'])) { $answer = $_POST['answer']; if($answer == $c) { echo "Correct!"; } else { exit("<p>Answer incorrect. Please hit back in your browser and try again</p>"); } } else { ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p><?php echo $a;?> + <?php echo $b;?> = <input type="text" name="answer" size="3" /></p> <input type="submit" name="submit" /> </form> <?php } ?> could anyone please set me straight? thanks in advance! Jason
  9. Thanks again for the insight on this guys, The last comment did the trick (my syntax was wrong).
  10. Sure thing: <?php if(isset($_POST['sendRequest'])) { $fleet = $_POST['fleet']; $contact = $_POST['contact']; $time = $_POST['start_month']." ".$_POST['start_day'].". ".$_POST['start_hour'].":".$_POST['start_minute']." ".$_POST['amPm']; $unit1 = array('Number' => $_POST['unit1'], 'Year' => $_POST['year1'], 'Make' => $_POST['make1'], 'Model' => $_POST['model1'], 'Glass' => $_POST['unit1Glass']); $unit2 = array('Number' => $_POST['unit2'], 'Year' => $_POST['year2'], 'Make' => $_POST['make2'], 'Model' => $_POST['model2'], 'Glass' => $_POST['unit2Glass']); $notes = $_POST['notes']; $msg = "Fleet: $fleet. Contact: $contact\n$unit1['Year'] $unit1['Make'] $unit1['Model'] $unit1['Glass']\n"; if(isset($_POST['unit2']) && $_POST['unit2'] != '') { $msg .= "$unit2['Year'] $unit2['Make'] $unit2['Model'] $unit2['Glass']\n"; } if this isn't enough code, i'd be happy to show whatever else might help. Thanks again!
  11. haha sorry i guess that info would help out... I'm getting an error on the line containing that code snippet "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in...blah blah blah"
  12. Hello everyone, I am trying to get values from some input forms and put them into an array but I'm not getting it. I would like to store some vehicle information that a user enters in a simple for in an array so i can use it in my app, but i think i'm screwing up the syntax... what am i doing wrong? $unit1 = array('Number' => $_POST['unit1'], 'Year' => $_POST['year1'], 'Make' => $_POST['make1'], 'Model' => $_POST['model1'], 'Glass' => $_POST['unit1Glass']); any insight, advice, hysterical comments encouraged and appreciated
  13. Still can't get this thing going... can anyone shed some light on this at all? thanks again in advance! J
  14. That makes a lot of sense (to me i think) and seems to simplify the code a bit. Thanks! However, I'm still having the same issue... the form process, but outputs nothing. The new attachment contains the updated code... Is this what you were talking about? [attachment deleted by admin]
  15. Thanks for a point in the right direction, but i'm still having some issues. The form is processing the info to itself, but when i try to echo out the parts(and properties) that have been inputted, they are coming up blank.... I've attached the code i'm working with with your suggestions added as well as some other little things i've tried to see if they would help get it working. I LOVE input, the good the bad and the ugly, so feel free to call it out when you see something that's stupid, newb-ish, etc! :-) thanks again, J [attachment deleted by admin]
  16. Hello again all, I'm working on a form and ran into a wall (again) and can't seem to think through how to best code what i need (the logic side). I've begun by just sitting down and starting to code with the little knowledge i have of php but can't seem to get it right and am not sure i'm using the correct syntax... The form is your basic contact form that collects contact information, but it also has a place for customers to input product information such as a quantity and dimensions (width and height). The form offers the visitor a chance to enter up to 7 different "products" and their quantity, width, and height.... here's that part of the form... <form name="myForm" action="<?php echo $_SERVER['PHP_SELF ']; ?>" method="POST"> <table width="600" cellspacing="2" cellpadding="1"> <tr> <td>Quantity</td> <td>Width</td> <td>height</td> </tr> <tr> <td><input type="text" name="qty1" /></td> <td><input type="text" name="width1" /></td> <td><input type="text" name="height1" /></td> </tr> <tr> <td><input type="text" name="qty2" /></td> <td><input type="text" name="width2" /></td> <td><input type="text" name="height2" /></td> </tr> <tr> <td><input type="text" name="qty3" /></td> <td><input type="text" name="width3" /></td> <td><input type="text" name="height3" /></td> </tr> <tr> <td><input type="text" name="qty4" /></td> <td><input type="text" name="width4" /></td> <td><input type="text" name="height4" /></td> </tr> <tr> <td><input type="text" name="qty5" /></td> <td><input type="text" name="width5" /></td> <td><input type="text" name="height5" /></td> </tr> <tr> <td><input type="text" name="qty6" /></td> <td><input type="text" name="width6" /></td> <td><input type="text" name="height6" /></td> </tr> <tr> <td><input type="text" name="qty7" /></td> <td><input type="text" name="width7" /></td> <td><input type="text" name="height7" /></td> </tr> </table> </form> ... pretty simple stuff there... I am having trouble though collecting the info from the form... the newbie in me (to php and programming in general) had me begin hard coding each variable like this... $qty1 = $_POST['qty1']; $qty2 = $_POST['qty2']; .... $width1 = $_POST['qty1']; $width2 = $_POST['qty2']; .... $height1 = $_POST['qty1']; $height2 = $_POST['qty2']; .... I thought that it might make more sense (and help me learn a little) to try and use a loop to create these variables.... is this good practice? Here's what i came up with... for ($X=1;$X < sizeof($glass1)-1; $X++) { // how's the syntax on the next line??? if($_POST['Qty'.$X]!=NULL ){ $glasspart1.="Part $X\n"; //below: can i use $qty$X like that? $glass1 = array("QTY: $qty$X", "DIMENSIONS: $width$X X $height$X"); $glasspart1.= "$glass1[$X-1]\n"; } } am i on the right track so far? I still am having trouble validating the form (the logic) in order to only create arrays for the parts (1-7) that were filled in, but i can save that for another post :-) thanks again all for any help or advice!! J
  17. Awesome bro! thanks... i'll play around with it... to be honest, the only reason i was hoping to serve the static pages was to see if search engines would like it more... have you had any experience with static vs dynamic pages in terms of SEO? Don't give away any secrets but if i can avoid javascript and use a single php page with no detrimental effects, i'd be loving life right now :-) thanks again! J
  18. hello again all, I'm creating a simple dropdown form for a site i'm working on and ran into a wall: I'd like to have a simple form that shows a few products, lets the user select a product and hit a submit button that will lead them to a static page that talks about that particular product. I know that i could use one products page and populate different content based on the selected option, but i'd like to try out using multiple static pages... what do you all think? here's what i have so far.... <html> <head></head> <body> <form name="myForm" action="" method="post"> <select name="product"> <option value="Product 1">Product 1</option> <option value="Product 1">Product 1</option> <option value="Product 1">Product 1</option> </select> <input type="submit" name="submit" value="Go!" /> </form> </body> </html> Pretty simple stuff.... as you can see I don't have anything in the action as of yet... i'm a little confused how to make this work but the idea would be that in my site's folder i would have static pages made for each of the products in the list. So in my newbish mind i would have to do something to change the action to match whichever selection has been made... Is that logic correct? redundant? just plain fail? haha thanks in advance! J
  19. Thanks a bunch! I'll take your suggestions and go from there. Much appreciated! J
  20. Hello all, I'm working on a website that i'd like to have dynamically served meta tags based on the search query they've entered on a search page of my site, but i'm hitting a wall. My search page is pretty simple and when searched will display a search results page with a URL like this: http://www.MySite.net/search.php?q=auto%20repair%20<myCity> each of the pages of the search result (and the site for that matter) have an include pointing to the following file: brains2.php <?php $referer = $_SERVER[HTTP_REFERER]; if($referer) { //if referer exists preg_match("/[\&\?]q=([^&]*)/", $referer, $matches); //search for special chars in the referer and //create an array of all the matches ($matches) if($matches[1]) { //if matches exist $search_query = rawurldecode($matches[1]); //replace things like "%20" and "%40 with " " and "@" //and assign the new value to $search_querry $search_query = str_replace("+", " ", $search_query); // replace plus sighns with spaces //and assign the new value to $search_querry } $dbcnx = @mysql_connect('myHost', 'myUser', 'myPassword'); //connect to database server if (!$dbcnx) { echo '<p>'.'Unable to connect to database server'.'</p>'; exit(); } if (!@mysql_select_db('seo')) { //select the database exit ('<p>'.'unable to connect to the database'.'</p>'); } $result = @mysql_query('SELECT city FROM citynames where city in '.$search_query); //query the database to get the city names if ($result) { $city = $result; setcookie('cityname', '$result'); } } else { $city="City1, City2, and City3"; setcookie('cityname', '$city'); } ?> The basic idea is that the user will click on a search result that will dynamically change the city refered to in the meta tags and content by calling the variable $city that's stored in the cookie (created by 'brains2.php'). Obviously, this isn't working... i can't seem to get the variable '$search_query' to hold a value... what am i missing here? Is there any flaws in my logic? Thanks guys and gals! Your help is always appreciated! J
  21. Finally got it just about finished... thanks so much LoneWolf and Ken for you insight and help! Everything is working great now with the required fields accept for one little thing... I can submit this form without having anything in the name field as long as i have an email address or phone number... what am i leaving out? revised code (thanks again guys!): <?php if (!isset($_POST['sendMeNow'])) { ?> <html> <head> <script type="text/javascript"> function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } function checkPhoneEmail() { if((document.getElementById('email').value=='' || document.getElementById('email').value==null) && (document.getElementById('phone').value=='' || document.getElementById('phone')==null)) { alert("You must fill in a contact mehod: Phone or Email"); return false; } else { return true; } } </script> </head> <body> <form name="contact" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> <table width="550" cellpadding="2" cellspacing="2"> <tr> <td><select name="serviceCenter" onchange="document.contact.submit();"> <option>Select Location</option> <option value="Location 1" <?php if ($_REQUEST['serviceCenter'] == 'Location 1') {echo 'selected="selected"';}?>>Location 1</option> <option value="Location 2" <?php if ($_REQUEST['serviceCenter'] == 'Location 2') {echo 'selected="selected"';}?>>Location 2</option> <option value="Location 3" <?php if ($_REQUEST['serviceCenter'] == 'Location 3') {echo 'selected="selected"';}?>>Location 3</option> </select></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> <?php switch ($_REQUEST['serviceCenter']) { //check serviceCenter value case 'Location 1': //if the value is Auburn Hills, MI then display the map ?> <div id="google-map"> <!-- insert map code here --> </div> <div id="location-info"> <!-- location information here --> </div> <br /> <?php break; case 'Warren, MI': //if the value is Warren, MI then display the map ?> <div id="google-map"> <!-- insert map code here --> </div> <div id="location-info"> <!-- location information here --> </div> <br /> <?php break; case 'Newark, DE': //if the value is Newark, DE then display the map ?> <div id="google-map"> <!-- insert map code here --> </div> <div id="location-info"> <!-- location information here --> </div> <br /> <?php break; default: ?> <br /> <?php } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" onsubmit="return checkPhoneEmail()"> <table width="550" cellpadding="2" cellspacing="2"> <tr> <td>Name:</td> <td><input type="text" name="name" /></td> <td> </td> <td> </td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email" id="email" /></td> <td> </td> <td> </td> </tr> <tr> <td>Phone:</td> <td><input type="text" name="phone" id="phone" maxlength="10" /></td> <td> </td> <td> </td> </tr> <tr> <td>Message:</td> <td><textarea name="message" cols="40" rows="7"></textarea></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><input type="submit" name="sendMeNow" value="Submit" onClick="MM_validateForm('name','','R','email','','NisEmail','phone','','NisNum');return document.MM_returnValue" /> <input type="reset" name="reset" value="Reset" /></td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> <?php } else { $name=$_REQUEST['name']; $phone = stripslashes($_REQUEST['phone']); $email = $_REQUEST['email']; $location = $_REQUEST['serviceCenter']; $serviceCheck = ''; foreach ($_REQUEST['serviceType'] as $value) { $serviceCheck .= "\n $value"; } $message = $_REQUEST['message']; switch ($_REQUEST['serviceCenter']) { case 'Location 1': $to = "location1@store.net"; break; case 'Location 2': $to = "location2@store.net"; break; case 'Location 3': $to = "location3@store.net"; break; default: $to = "location1@store.net"; break; } $msg = "You have received a message from your website's 'Contact Page'. The information the visitor submitted can be seen below:\n\n\n\nContact Information\n\nName: $name\nPhone: $phone\nEmail: $email\n\nService Requested: $serviceCheck\n\nMessage:\n$message"; mail("$to", "Contact from the website", "$msg", "From: $email"); ?> <html> <head></head> <body> Thank you... </body> </html> <?php } ?>
  22. just a question from a newb... for the number 2. answer you gave, why does the first form need that attribute? the first form should only be asking them to select from a drop down menu and the second form will have the input fields. (not trying to argue, just trying to understand )
  23. Aye Ken, and thanks for the reply. The more i learn about coding the less i like dreamweaver in general!! Sorry i didn't explain what's wrong with the code haha (oops). With the code i've provided last, i can submit the form without filling in ANY fields. I would like the name to be required, the email (if entered) in the correct format and the phone (if entered) to be a number. Per the earlier post, it doesn't matter to me if the visitor enters in the email or the phone, but we need them to enter one of them. Again, sorry for leaving all that out!
×
×
  • 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.