Jump to content

Luke Martin

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Luke Martin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. How would I generate a Msgbox from the PHP. I tried this but gives me a server 500 error if ($success){header('Location: '.$_POST['return']); alert(document.getElementById('return').value); exit(); } This obviously work within the HTM file onsubmit...but id like one message box for "Message success" and a different one for "Message fail" (which in theory, given the current lack of validation, would never appear...but want there for future devel) Thoughts?
  2. Hmmmm....could you provide an example based on my script. My only fear is that they will enter something like "mobile 07725635620" and then the script will dump them back...and they wont be bothered to correct Would rather just allow them to blindly submit...everything is captured and sent to my info@ mailbox. UNLESS!!! I'm guessing if I wanted validation it would be more difficult....as i would like it to tell the user what was incorrect....in a message box and then make them correct it before the form submits to pHP Wouldnt this need to be java....as I want to keep the file as HTM I struggled to get the script to this stage. I would validation but have no web program knowledge
  3. Ok The reason I didnt want validation it that this form will be voluntary....so i dont want to force potential clients to enter an email address etc if they dont have one...thus preventing them from submitting the sheet. This script should work every time (as there is no validation) so an error event would only occur if the server was down, correct? I would ideally like it so that if it was a success "Thank you for your enquiry" message box, else produce "Error : Please try again" (which should never occur) message box using the alert(document.getElementById('return').value) style popup that is currently sat on the HTM...but may be better in the PHP file where you do the IF statement ??? How would this look? nearly done...at least it works now!
  4. Also somebody said I should put my variable like this ? $Company = (isset($_POST['Company'])) ? trim(stripslashes($_POST['Company'])) : FALSE; As there is no validation.....am i correct in thinking I will never have a need for an error page? If i ever developed such a need...would it be possible to tell the user in a message box where the errors are before posting the HTM to PHP ?
  5. How would yours vary to mine...other than being more compact...(now works) : // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){header('Location: '.$_POST['return']); exit(); } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> So where I have an IF statement....yours would just run and if it runs successfully, it will do the redirect? Sorry im learning as i go, first PHP!
  6. But this is what im saying...if I remove the bit at the bottom...everything works fine and the mails post!?
  7. In fact....I just loaded the below which has the desired effect....re-directs me back ; <?php header('Location: '.$_POST['return']); exit(); ?> So it must be something else....the script above it works fine on its own (email post script) but the two dont work together!
  8. Hmmmm confusing....it echoes the URL i came from..so the variable is passing across to PHP correctly So it must be this element causing the harm ? : header('Location: '.$_POST['return']); exit();
  9. Hmmm i created it... <?php echo out $_POST['return'] } ?> I get server 500 error again Every other variable feeds through but this return clearly isn't, although it is present in the HTM prior to POST Something to do with fasthosts being poo as usual? (Not sure what that <meta> refresh thing does, just came off a generator...this is my first PHP)
  10. I will adjust this going forward...sorry But I know it works (although it is scruffy) in its current...the elements that are failing me are : In the HTM file : <input type="hidden" name="return" id="return" /> I know the variable is being recorded correctly as the onSubmit action production an alert, verifying the URL (for testing). But it doesn't seem to be making it through to the PHP file...as dumps me at 500 error header('Location: '.$_POST['return']); exit(); The script worked fine, i just wanted to add this so the user would be redirected back to then page they came from after submit...
  11. Hi I am using this form www.gruffe.co.uk/contact.htm It should pass a variable called 'return' to the php form (www.gruffe.co.uk/contact.php) But whenever I run it I get a server 500 error! The code in the PHP is as follows : <?php // Website Contact Form Generator // http://www.tele-pro.co.uk/scripts/contact_form/ // This script is free to use as long as you // retain the credit link // get posted data into local variables $EmailFrom = "info@gruffe.co.uk"; $EmailTo = "info@gruffe.co.uk"; $Subject = "Webmail Enquiry"; $First = Trim(stripslashes($_POST['First'])); $Last = Trim(stripslashes($_POST['Last'])); $Company = Trim(stripslashes($_POST['Company'])); $Address = Trim(stripslashes($_POST['Address'])); $Telephone = Trim(stripslashes($_POST['Telephone'])); $Mobile = Trim(stripslashes($_POST['Mobile'])); $Website = Trim(stripslashes($_POST['Website'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "First: "; $Body .= $First; $Body .= "\n"; $Body .= "Last: "; $Body .= $Last; $Body .= "\n"; $Body .= "Company: "; $Body .= $Company; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $Telephone; $Body .= "\n"; $Body .= "Mobile: "; $Body .= $Mobile; $Body .= "\n"; $Body .= "Website: "; $Body .= $Website; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); header('Location: '.$_POST['return']); exit(); } ?>
×
×
  • 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.