Jump to content
The mkiv Supra Owners Club

Any web developers??


bondango

Recommended Posts

need someone to look at some script (Form) that im working on, cant seem to get the data across to a PHP script.

 

HTML :-

 

 

 

 

 

 

 

 

 

which im trying to pass to this

PHP script (contact.php)

 

<?php

ARRIVED AT PHP

if(isset($_POST['email'])) {

 

// EDIT THE 2 LINES BELOW AS REQUIRED

$email_to = "[email protected])";

$email_subject = "web query";

 

 

$email_message = "Form details below.\n\n";

 

function clean_string($string) {

$bad = array("content-type","bcc:","to:","cc:","href");

return str_replace($bad,"",$string);

}

 

$email_message .= "Name: ".clean_string($name)."\n";

$email_message .= "contact: ".clean_string($phone)."\n";

$email_message .= "Email: ".clean_string($email)."\n";

$email_message .= "postcode".clean_string($post)."\n";

$email_message .= "Vehicle: ".clean_string($vehicle)."\n";

$email_message .= "Reg: ".clean_string($reg)."\n";

$email_message .= "Other: ".clean_string($other)."\n";

 

 

// create email headers

$headers = 'From: '.$email_from."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();

@mail($email_to, $email_subject, $email_message, $headers);

?>

 

 

Thank you for contacting us. We will be in touch with you very soon.

 

}

?>

 

 

dont think im arriving at the PHP as the message i have inserted dosnt show. being looking at this for 2 hours now and my head hurts

 

Ps when i het it working il be putting in captha (sp)

Marty

Link to comment
Share on other sites

Evening. The message won't display as you written it inside the <?php tag. If you want it to display a message wrap it in an echo statement, e.g. echo("my message");

 

Also your querying the 'post' array when you submitted the form as a 'get'. Try method="post" rather than method="get".

 

Cheers.

Link to comment
Share on other sites

As optim8 said, change your form method to post. But also you need to "return false" at the end of your form submit onclick, otherwise it will just follow the href (in this case just refresh the page). Here you go:

 

Submit

 

Is there any reason why you are using an "a" with an onclick rather than a "submit" input type? As should the form user have javascript disabled they wont be able to submit the form (which may not matter, depending on your audience).

 

Also ARRIVED AT PHP isnt commented out, so change that to // ARRIVED AT PHP

Link to comment
Share on other sites

As optim8 said, change your form method to post. But also you need to "return false" at the end of your form submit onclick, otherwise it will just follow the href (in this case just refresh the page). Here you go:

 

Submit

 

Is there any reason why you are using an "a" with an onclick rather than a "submit" input type? As should the form user have javascript disabled they wont be able to submit the form (which may not matter, depending on your audience).

 

Also ARRIVED AT PHP isnt commented out, so change that to // ARRIVED AT PHP

 

 

 

Well that seems to be passing it to the PHP script now. To be honest, this web malarky isnt my thing lol.

I would like the information pushed to the contact.php page but not the user i.e. when they click submit the page refreshes but the information is still passed to the contact script

Link to comment
Share on other sites

Here's an example script from W3C Schools. Does what you want basically, just need to change the input fields.

 

 

<?php

if (isset($_REQUEST['email']))

//if "email" is filled out, send email

{

//send email

$email = $_REQUEST['email'] ;

$subject = $_REQUEST['subject'] ;

$message = $_REQUEST['message'] ;

mail( "[email protected]", "Subject: $subject",

$message, "From: $email" );

echo "Thank you for using our mail form";

}

else

//if "email" is not filled out, display the form

{

echo "

Email:

 

Subject:

 

Message:

 

 

";

}

?>

 

Link to comment
Share on other sites

think i'll stick to cars...

 

<?php

echo "arrived?"

if(isset($_POST['email'])) {

print '

';

print_r($_POST);

print '

';

 

exit();

// EDIT THE 2 LINES BELOW AS REQUIRED

$email_to = "[email protected]";

$email_subject = "Scrap/damaged/sale query";

 

 

$email_message = "Form details below.\n\n";

 

function clean_string($string) {

$bad = array("content-type","bcc:","to:","cc:","href");

return str_replace($bad,"",$string);

}

 

$email_message .= "Name: ".clean_string($name)."\n";

$email_message .= "contact: ".clean_string($phone)."\n";

$email_message .= "Email: ".clean_string($email)."\n";

$email_message .= "postcode".clean_string($post)."\n";

$email_message .= "Vehicle: ".clean_string($vehicle)."\n";

$email_message .= "Reg: ".clean_string($reg)."\n";

$email_message .= "Other: ".clean_string($other)."\n";

 

 

// create email headers

$headers = 'From: '.$email_from."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();

@mail($email_to, $email_subject, $email_message, $headers);

?>

 

 

 

 

 

}

?>

Link to comment
Share on other sites

Here you go:

 

<?php

 

if(isset($_POST['email'])) {

 

print '

';

print_r($_POST);

print '

';

 

exit();

// EDIT THE 2 LINES BELOW AS REQUIRED

$email_to = "[email protected]";

$email_subject = "Scrap/damaged/sale query";

 

$email_message = "Form details below.\n\n";

 

function clean_string($string) {

$bad = array("content-type","bcc:","to:","cc:","href");

return str_replace($bad,"",$string);

}

 

$email_message .= "Name: ".clean_string($name)."\n";

$email_message .= "contact: ".clean_string($phone)."\n";

$email_message .= "Email: ".clean_string($email)."\n";

$email_message .= "postcode".clean_string($post)."\n";

$email_message .= "Vehicle: ".clean_string($vehicle)."\n";

$email_message .= "Reg: ".clean_string($reg)."\n";

$email_message .= "Other: ".clean_string($other)."\n";

 

 

// create email headers

$headers = 'From: '.$email_from."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();

@mail($email_to, $email_subject, $email_message, $headers);

?>

 

Include your own success html here

 

<?php

}

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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. You might also be interested in our Guidelines, Privacy Policy and Terms of Use.