Extra \ when hit Submit Button

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TD_M3
Forum Newbie
Posts: 2
Joined: Fri Jun 25, 2010 7:42 am

Extra \ when hit Submit Button

Post by TD_M3 »

Hi,

Let me start off by saying I am new to PHP. I have inserted a html snippet in an Iweb project. Below is the code i have in there. I don't know why but when i hit the submit button, i get an extra '/' like so : http://testdomain.com/iwebprj[b]//[/b]Contact_Us_files/send_form_email.php

I have no clue why. Any help would be appreciated.

--------------------------------------------
<form name="contactform" method="post" action="send_form_email.php">
<table width="450px">
</tr>
<tr>
<td valign="top">
<label for="first_name">First Name *</label>
</td>
<td valign="top">
<input type="text" name="first_name" maxlength="50" size="30">
</td>
</tr>

<tr>
<td valign="top"">
<label for="last_name">Last Name *</label>
</td>
<td valign="top">
<input type="text" name="last_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email Address *</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30">
</td>

</tr>
<tr>
<td valign="top">
<label for="telephone">Telephone Number</label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="30" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="comments">Comments *</label>
</td>
<td valign="top">
<textarea name="comments" maxlength="1000" cols="28" rows="6"></textarea>
</td>

</tr>
<tr>
<td colspan="2" style="text-align:left">
<input type="submit" value="Submit">
</td>
</tr>
</table>
</form>


--------------------------------------------
phpfreak2000
Forum Newbie
Posts: 3
Joined: Fri Jun 25, 2010 11:17 am

Re: Extra \ when hit Submit Button

Post by phpfreak2000 »

Even though this is HTML (the most basic code there is) i cant see the problem with it, although its something simple (like mostly) :D

Well ill try to take a look at it here and see, otherwise ive no clue, sorry :D


edit: after have tried it here, i dont get that problem, so i dont know what its....
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Extra \ when hit Submit Button

Post by internet-solution »

TD_M3 wrote: I don't know why but when i hit the submit button, i get an extra '/' like so : http://testdomain.com/iwebprj[b]//[/b]Contact_Us_files/send_form_email.php
Where do you get the '/' ? in http post request? If you post the code in send_form_email.php, it may will be easier to debug.
TD_M3
Forum Newbie
Posts: 2
Joined: Fri Jun 25, 2010 7:42 am

Re: Extra \ when hit Submit Button

Post by TD_M3 »

Here is the php.


<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "td@stdhanraj.com";
$email_subject = "WebSite Inquiry";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}

// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form your submitted.');
}

$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required

$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!eregi($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
$string_exp = "^[0-9 .-]+$";
if(!eregi($string_exp,$telephone)) {
$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$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 .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\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 -->

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

<?
}
?>
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Extra \ when hit Submit Button

Post by Jonah Bron »

The submit action is set to "send_form_email.php". Providing the file is in the same folder as the page you first provided, it will go straight there. Do you mean that when you submit the form you gave, you are taken to /iwebprj//Contact_Us_files/send_form_email.php? As far as I know, that's impossible. A double forward slash (//) indicates the address of the root. So, /iwebprj//Contact_Us_files/send_form_email.php is the same as /Cantact_Us/send_form_email.php

Please clarify the problem.
Post Reply