I have a recent issue with a $_POST.
When I write :
print_r($_POST['nb_acces']);
I get :
1
Which is the value I wrote in the form.
But if I write :
$nb_acces = $_POST['nb_acces'];
print_r($nb_acces )
I get :
Array ( [nb] => 0 )
It was working before, and now I don't understand what happens. Could it be from a server configuration or something ?
EDIT :
My input :
<form id='sous_paiement' name='sous_paiement' method='post' action='commande_enregistre_test.php?ecole=<?php echo $id_ecole; ?>'>
<input id='nb_acces' name='nb_acces' style='width:90px;border:1px solid black;padding-left:4px;text-align:center;' />
Yes if I use $_POST['nb_acces'] I can echo the value. Though I wish to check the value to have an integer and avoid injection.
The way I get this array is the point I don't understand. I have only one input.
Could it come from my checking JavaScript function (sorry for french words, I remove here any non digit characters and calculate some prices) :
function filtre_saisie() {
var input_acces = document.getElementById("nb_acces");
var nb_acces = input_acces.value.replace(/[^0-9]/g, '');
input_acces.value = nb_acces;
var prix_unitaire = calcul_prix_unitaire(nb_acces);
var prix_total = calcul_prix_total(nb_acces);
document.getElementById("div_prix_unitaire").innerHTML = prix_unitaire;
document.getElementById("div_prix_total").innerHTML = prix_total;
}
Could it be this replace ?
EDIT 2 ----------------------------------
Well the whole form :
<form id='sous_paiement' name='sous_paiement' method='post' action='commande_enregistre_test.php?ecole=<?php echo $id_ecole; ?>'>
<div class="div_categories">
<p style='margin:0;padding:3px;padding-left:60px;'>Indiquez le <strong>nombre d'accès</strong> que vous souhaitez acheter :</p>
</div>
<br />
<div id="erreur_nb_acces" style="color:red;"><br /></div>
<table style='border-collapse:collapse;'>
<tr style='font-weight:bold;border:1px solid #eee;background-color:white;'>
<td style='width:200px;padding-left:10px;'>Nombre d'accès</td>
<td style='width:100px;padding-left:10px;padding-right:10px;'><input id='nb_acces' name='nb_acces' type="text" style='width:90px;border:1px solid black;padding-left:4px;text-align:center;' /></td>
</tr>
</table>
<br />
<table style='border-collapse:collapse;'>
<tr style='border:1px solid #eee;background-color:white;border-bottom:1px solid #999;'>
<td style='width:200px;padding-left:10px;'>Prix par accès</td>
<td style='width:100px;padding-left:10px;padding-right:10px;text-align:right;'><div id='div_prix_unitaire' style='display:inline;'>-</div> €</td>
</tr>
<tr style='font-weight:bold;border:1px solid #999;background-color:white;'>
<td style='width:200px;padding-left:10px;'>PRIX TOTAL</td>
<td style='width:100px;padding-left:10px;padding-right:10px;text-align:right;'><div id='div_prix_total' style='display:inline;'>-</div> €</td>
</tr>
</table>
<div style='width:190px;margin-top:5px;'>
Consulter les tarifs</span>
</div>
<div style="clear:both;"></div>
<br /><br />
<div class="div_categories">
<p style='margin:0;padding:3px;padding-left:60px;'>Choisissez votre <strong>mode de paiement</strong> :</p>
</div>
<br /><br />
<table class="tab_mode_paiement" style="border-collapse:collapse;">
<tr>
<td>
<input id='paiement_cb' name='mode_paiement' value='5' class='eleves' type='radio' checked="checked" style="cursor:pointer" />
</td>
<td style="font-weight:bold;padding-right:80px;border-right:1px solid #999;">
<label for='paiement_cb' style="cursor:pointer">
<img src="../images/ic_cb.jpg" style="float:left;display:inline;padding-right:10px;" /> Carte bancaire
</label>
</td>
<td style="padding-left:40px;">
<!--<input id='paiement_paypal' name='mode_paiement' value='3' class='eleves' type='radio' style="cursor:pointer" />-->
</td>
<td style="font-family:arial;font-size:20px;padding-right:120px;">
<!--<label for='paiement_paypal' style="cursor:pointer">
<span style="color:rgba(0,3,128,1)">Pay</span><span style="color:rgba(0,158,210,1)">Pal</span>
</label>-->
</td>
<td>
<input id='paiement_virement' name='mode_paiement' value='1' class='eleves' type='radio' style="cursor:pointer" />
</td>
<td style="font-weight:bold;">
<label for='paiement_virement' style="cursor:pointer">
Par virement bancaire
</label>
</td>
</tr>
<tr>
<td colspan="2" style="border-right:1px solid #999;">Recevez vos accès immédiatement</td>
<td colspan="4" style="padding-left:90px;">Accès disponibles après réception du paiement</td>
</tr>
</table>
<br /><br /><br />
<input id='enregistrer' name='enregistrer' value='Enregistrer la commande' type='button' onclick='verif_sous_paiement();' style='width:300px;height:40px;' />
<br /><br />
<br />
</form>
And my Javascript :
<script>
function ouvrirPopUp_tarifs() {
window.open ('tarifs.php', 'tarifs', config='height=370, width=760, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no');
}
var tab_responsables = new Array();
var tab_acces_responsables = new Array();
var nb_responsables = 0;
function initialiser_filtre_saisie() {
setInterval("filtre_saisie()", 200);
}
function filtre_saisie() {
var input_acces = document.getElementById("nb_acces");
var nb_acces = input_acces.value.replace(/[^0-9]/g, '');
input_acces.value = nb_acces;
var prix_unitaire = calcul_prix_unitaire(nb_acces);
var prix_total = calcul_prix_total(nb_acces);
document.getElementById("div_prix_unitaire").innerHTML = prix_unitaire;
document.getElementById("div_prix_total").innerHTML = prix_total;
}
function verif_sous_paiement() {
filtre_saisie();
var nb_acces = document.getElementById("nb_acces").value;
if (nb_acces == 0) {
document.getElementById("erreur_nb_acces").innerHTML = "Veuillez indiquer un <strong>nombre d'accès</strong>.";
document.getElementById('nb_acces').focus();
}
else {
document.getElementById('sous_paiement').submit();
}
}
</script>
Seems my whole code afraid everybody -.-
You are missing the type="text" attribute in your input, even the browser asumes that's a text, this might cause you some problems;
<input type="text" id='nb_acces' name='nb_acces' .......... />
Also, seems like you're replace anything that starts with a number, like 1 with a empty value, that's why you get a 0:
var nb_acces = input_acces.value.replace(/\d/g, '')
Well, I saw the message of someone who told me to check with var_dump, and it helped me to figure now why there is this issue. I don't know why this message has been erased as it helped me a lot. Thanks to who posted it.
If someone has the same issue, but I know it comes from an old and probably bad server configuration, to use $nb_acces and $_POST['nb_acces'] generates a conflict. Don't use the same name. That's all -.-
Related
Recently I moved my codeigniter website to a new server (goddady). Before this everything was working great with no problems. But now I started to get strange problems with post data, whenever I try to insert data that contains relative paths with dots (../../) and try to submit the form, I get an empty $_POST array. The strange thing is that this happens only with certain forms, not all of them. What could cause such problem?
Here is the form that causes problem:
<?php
if(isset($posts2) && count($posts2) == 1){
$posts2 = $posts2[0];
echo form_open_multipart('professors/update_biography/', array("id" => "professors_edit"));
echo form_hidden('posts2[id]', $posts2->id);
if(isset($user) && count($user) == 1){
$user = $user[0];
echo form_hidden('user[id]', $user->id);
echo form_hidden('user[role]', "Professor");
}
?>
<table class="admin_table">
<tr>
<th>
Биографија
</th>
<td>
<textarea name='posts2[biography]'><?php echo $posts2->biography; ?></textarea>
</td>
</tr>
<tr>
<th>
Биографија EN
</th>
<td>
<textarea name='posts2[biography_en]'><?php echo $posts2->biography_en; ?></textarea>
</td>
</tr>
<tr>
<th>
Cv
</th>
<td>
<p class="old">CV</p>
<input type="file" name='cv' id="pdf"></input>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type='submit' name='submit' value='Зачувај' />
</td>
</tr>
</table>
<?php
echo form_close();
?>
<div class="redButton" style="float:left; width: 150px;">
<?php
if(!isset($prof[0]->id)){ //da ne go prikazuva za profesor
echo anchor('professors/', 'Назад до професори');
}
?>
</div>
<?php
}
?>
I am having problem in this situation, i searched alot and don't know what should i do with it....
I have got like 4 checkboxes, on each checkbox a certain function is being performed. I have this html code for checkboxes,
<form action="check.php" method="post">
<table border="1" width="200">
<tr>
<td>
<input type="checkbox" name="first[]" value="option1" />
</td>
<td width="500">
<strong>Option 1</strong>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="first[]" value="option2" />
</td>
<td width="500">
<strong>Option 2</strong>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="first[]" value="option3" />
</td>
<td width="500">
<strong>option 3</strong>
</td>
</tr>
</table>
<table border="1" width="200">
<tr>
<td>
<input type="text" name="entered_value"/>
</td>
</tr>
</table>
<table border="1" width="200">
<tr>
<td>
<input type="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
I am accessing these checkboxes using this code
<?php
if (isset($_POST['submit']))
{
if(isset($_POST['first']))
{
$get_data_checkboxes = $_POST['first'];
}
else
{
$get_data_checkboxes = "";
}
print_r($get_data_checkboxes);
exit();
}
?>
What i am facing problem is like i need to run a function on each checkbox ticked, e.g. if the person ticks Option 1 then i should be able to run function 1 and so on...
any help will be appreciated :)
If you want to select multiple checkboxes, you can try something like this:
for( $i = 0; $i < count( $_POST['first'] ); $i++ ) {
if( $_POST['first'][$i] == 'option1' ) {
echo "function1";
} else if( $_POST['first'][$i] == 'option2' ) {
echo "function2";
} else if( $_POST['first'][$i] == 'option3' ) {
echo "function3";
}
}
You don't need the line
if (isset($_POST['submit']))
Without that your code works fine, and you can use that to call your functions like this:
<?php
if(isset($_POST['first']))
{
$get_data_checkboxes = $_POST['first'];
foreach($get_data_checkboxes as $value){
//call functions named option1(), option2(), etc..
call_user_func($value);
}
}
else{
$get_data_checkboxes = "";
}
?>
I am trying to use a jquery to have text boxes and little pluses and minuses to add and delete them when required. It displays the data from MySQL but you can't delete them and you can only add them
Here is a link to a webpage i am using
http://adamlisik.co.uk/epq2/models/certificate.php?certid=250631166
I want to find a way that the text boxes that are displayed with the data from db can be deleted
<script type="text/javascript">
$(document).ready(function(){
// tworzymy zmienną i, wykorzystamy ją do identyfikowania wierszy
// ustawiamy jej wartość 2, ponieważ jeden wiersz jest już w tabeli
var i = 2;
// tworzymy zmienną szablonWiersza i wczytujemy do niej szablon z textarea #szablon
var szablonWiersza = jQuery.format($("#szablon").val());
// tworzymy funkcję, która dodaje szablon do właściwej tabeli
function dodajWiersz() {
var ii = i++;
// dodajemy wiersz do właściwej tabeli
$(szablonWiersza(ii)).appendTo("#listaOsob tbody");
// Nowy wiersz jest już widoczny.
// Każdy element nowego wiersza posiada swoje id
// tr na id: wiersz_2, ikona minus ma id: usunOsobe_2
// Do nowo dodanej ikony - dodajmy zdarzenie.
// W momencie kliknięcia minusa, wiersz zostanie usunięty.
$("#usunOsobe_" + ii).click(function(){
$("#wiersz_" + ii).remove();
});
}
// do przycisku #dodajOsobe dodajemy zdarzenie,
// kliknięcie na przycisk plus wywoła fukcję dodajWiersz
$("#dodajOsobe").click(dodajWiersz);
});
</script>
<h1>Sixth form baccaluraureate</h1>
<div id="content">
<textarea id="szablon" style="display:none;" cols="1" rows="1">
<tr id="wiersz_{0}">
<td><input type="text" name="name[]" ></td>
<td><input type="text" name="hours[]"></td>
<td><input type="hidden" name="certificate_id[]"value="<?php echo $table2[0][2]; ?>">
<td><img src="http://antczak.org/source/dynamic_forms/12.png" id="usunOsobe_{0}" alt="usun"></td>
</tr>
</textarea>
<!-- Właściwa tabela -->
<h4>activities form</h4>
<form action="update_certificate.php" method="post">
<!-- do not delete student is!!!! because we need it in confirm_cert.php-->
<input type="hidden" name="student_id" value="<?php echo $row[0] ?>" /> <br />
<input type="hidden" name="student_id2" value="<?php echo $row[3] ?>" /> <br />
<input type="hidden" name="certificate_number" value="<?php echo $certificate_name; ?>" />
<br/>
<table id="listaOsob">
<thead>
<tr>
<th>Activity name</th>
<th>Hours</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$a=0;
while($a<sizeof($table2)){
echo "<tr><td><input type='text' name='name[]' value='".$table2[$a][0]."'></td>";
echo "<td><input type='text' name='hours[]' value='".$table2[$a][1]."'></td>";
echo "<td><input type='hidden' name='certificate_id[]' value='".$table2[$a][2]."'></td>";
#echo $a;
if ($a==0){
echo "<td><img src='../view/11.png' id='dodajOsobe' alt='dodaj'></td></tr>";
}else{
echo "<td><img src='../view/12.png' id='usunOsobe_{0}' alt='usun'></td></tr>";
}
$a++;
}
?>
</tr>
</tbody>
</table>
<input type="submit" value="Submit" />
</form>
</div>
Perhaps you could use the jQuery .remove() function.
http://api.jquery.com/remove/
I am working on a website and I am having trouble getting a PHP mail script to send the contents of my form to an email. It is for the registration of students for a club. The link where you can view the current form is http://trhs-snowriders.com/register.htm and I would appreciate any help from anyone with experience with mail scrips and making sure they get delivered.
I own the server so I can make any tweaks that may be necessary
The Mail is being sent but is usually in the spam folder. The other problem I am having is the php script is not getting the values from the html form... Here is the html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<html>
<head>
<title>Timberlane Snowriders Registration</title>
<META http-equiv="last-modified" content="Module 3-1, 2010-12-16"/>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"/>
<!--Begin Custom JavaScript Form Validator-->
<script type="text/javascript">
function valbutton(thisform)
{
var l=document.forms["registrationForm"]["lastName"].value;
var f=document.forms["registrationForm"]["firstName"].value;
if (l==null || l=="")
{
alert("Last Name must be filled out!");
return false;
}
if (f==null || f=="")
{
alert("First Name must be filled out!");
return false;
}
if (document.registrationForm.level.selectedIndex==0)
{
alert("Please select your Skiing/Boarding ability!");
document.registrationForm.level.focus();
return false;
}
myOption = -1;
for (i=thisform.emergency.length-1; i > -1; i--) {
if (thisform.emergency[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select Yes or No");
return false;
}
myOption2 = -1;
for (i=thisform.consent.length-1; i > -1; i--) {
if (thisform.consent[i].checked) {
myOption2 = i; i = -1;
}
}
if (myOption2 == -1) {
alert("You must select Yes or No");
return false;
}
myOption3 = -1;
for (i=thisform.procedure.length-1; i > -1; i--) {
if (thisform.procedure[i].checked) {
myOption3 = i; i = -1;
}
}
if (myOption3 == -1) {
alert("You must select Yes or No");
return false;
}
thisform.submit();
}
</script>
<!--End custom JavaScript Form Validator-->
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
image1 = new Image();
image1.src=images/return_dark.gif;
image3 = new Image();
image3.src=images/prices_dark.gif;
image4 = new Image();
image4.src=images/members_dark.gif;
image5 = new Image();
image5.src=images/gallery_dark.gif;
image6 = new Image();
image6.src=images/fitness_dark.gif;
image7 = new Image();
image7.src=images/contact_dark.gif;
image8 = new Image();
image8.src=images/calendar_dark.gif;
image9 = new Image();
image9.src =images/emergency_dark.gif;
// End -->
</script>
</head>
<body background="images/silver-diamond-plate.jpg" link="black" vlink="blue" alink="red" marginheight="0" marginwidth="0" topmargin="0" bottommargin="0">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td width="1280" height="768">
<table align="center" width="1280" height="768" border="0" cellpadding="1" cellspacing="2" align="left">
<tr>
<td rowspan="10" width="250" height="760" align="center" valign="top" background="images/pats_sidebar.jpg" title="Night view of Pat's Peak">
<a href="index.htm" onmouseover="image1.src='images/return_dark.gif';" onmouseout="image1.src='images/return.gif';">
<img name="image1" src="images/return.gif" border="0"/ title="Return to Snowriders"></a>
<a href="register.htm" onmouseover="image2.src='images/registration_dark.gif';" onmouseout="image2.src='images/registration.gif';">
<img name="image2" src="images/registration.gif" border="0"/ title="Registration"></a>
<a href="prices.htm" onmouseover="image3.src='images/prices_dark.gif';" onmouseout="image3.src='images/prices.gif';">
<img name="image3" src="images/prices.gif" border="0"/ title="2010 Prices"></a>
<a href="members.htm" onmouseover="image4.src='images/members_dark.gif';" onmouseout="image4.src='images/members.gif';">
<img name="image4" src="images/members.gif" border="0"/ title="Members"></a>
<a href="gallery.htm" onmouseover="image5.src='images/gallery_dark.gif';" onmouseout="image5.src='images/gallery.gif';">
<img name="image5" src="images/gallery.gif" border="0"/ title="Photo Gallery"></a>
<a href="fitness.htm" onmouseover="image6.src='images/fitness_dark.gif';" onmouseout="image6.src='images/fitness.gif';">
<img name="image6" src="images/fitness.gif" border="0"/ title="Getting in Shape"></a>
<a href="contact.htm" onmouseover="image7.src='images/contact_dark.gif';" onmouseout="image7.src='images/contact.gif';">
<img name="image7" src="images/contact.gif" border="0"/ title="Contact Us"></a>
<a href="calendar.htm" onmouseover="image8.src='images/calendar_dark.gif';" onmouseout="image8.src='images/calendar.gif';">
<img name="image8" src="images/calendar.gif" border="0"/ title="Contact Us"></a>
<a href="faq.htm" onmouseover="image9.src='images/question_dark.gif';" onmouseout="image9.src='images/question.gif';">
<img name="image9" src="images/question.gif" border="0"/ title="Frequently Asked Questions"></a>
<a href="emergency.htm" onmouseover="image10.src='images/emergency_dark.gif';" onmouseout="image10.src='images/emergency.gif';">
<img name="image10" src="images/emergency.gif" border="0"/ title="Emergency"></a>
</tr></td>
<tr>
<td colspan="2" width="1030" height=226 rowspan="1" colspan="1" align="center" valign="top">
<img src="images/registration.jpg" title="Snowriders main banner"</td>
<tr>
<td bgcolor=silver colspan="2" width="1030" height="100" align="center" valign="middle">
<font face="arial" color=red size="6"><b>Status:</b></font></p>
<font face="arial" color=navy size="5"><b>We are currently registering members for 2011- 2012.<br/>Check the members listing here:</b></p></font>
</td>
</tr>
<td background="images/opacity1.JPG" colspan="2" width="1030" height="300" rowspan="1" colspan="1" align="left" valign="top"><font face="Comic Sans MS" size=7 color=black></p> <center>Registration is first-come, first-served.<br/>Complete the following SIX steps: </center></p></font>
<font face="Comic Sans MS" size=6 color=black>
<blockquote><ol type="decimal" start="1">
<li>Print and fill out the "Emergency Contact Form."</li>
<li>Read the "Warning and Consent Agreement."</li>
<li>Read the "Prices and Procedures sheet."</li>
<li>Fill in and submit the following form:<br/>
(This form will generate an e-mail, that will automatically be sent)</p></li>
</ol></blockquote>
</font></td>
</tr>
<td colspan="2" width="100%" rowspan="1" align="center" valign="top">
<form name="registrationForm" action="form2email.php" method="post" enctype="text/plain">
<input type="hidden" name="email" value="formsender#trhs-snowriders.com" />
<input type="hidden" name="redirect" value="http://trhs- snowriders.com/registercomplete.html#regcom" />
<center>
<table border="2" cellpadding="3" cellspacing="2" bgcolor="gray">
<tr>
<td align="right"><font face="Comic Sans MS" size="4"><b>Student's Last Name:</b></font> <input type="text" name="lastName" align="left" size="50"/></td>
</tr>
<tr>
<td align="right"><font face="Comic Sans MS" size="4"><b>Student's First Name:</b> <font> <input type="text" name="firstName" align="left" size="50"/></td>
</tr>
<tr>
<td align="right"><font face="Comic Sans MS" size="4"><b>Mother's Last Name (if different)</b></font> <input type="text" name="mother" align="left" size="50"/></td>
</tr>
<tr>
<td align="right"><font face="Comic Sans MS" size="4"><b>Father's Last Name (if different)</b></font> <input type="text" name="father" align="left" size="50"/></td>
</tr>
<tr>
<td align="right"><font face="Comic Sans MS" size="4"><b>What is your skiing/boarding ability?</b></font>
<select name="level">
<option selected> (please choose)</option>
<option>I've never skied/boarded before</option>
<option>I've had a few lessons and I can stop and turn</option>
<option>I can ski/board on easy slopes</option>
<option>I can ski/board on more challenging slopes</option>
<option>I can do it all!!</option>
</select>
</tr>
<tr>
<td align="right" ><font face="Comic Sans MS" size="4"><b>I have filled in, printed, and signed the "Emergency Contact" form.</b></font>
<input type="radio" name="emergency" value="Yes" /> Yes
<input type="radio" name="emergency" value="No" />No
</tr>
<tr>
<td align="right" ><font face="Comic Sans MS" size="4"><b>I have read and understand the "Warning and Consent Agreement."</b></font>
<input type="radio" name="consent" value="Yes" /> Yes
<input type="radio" name="consent" value="No" />No
</tr>
<tr>
<td align="right" ><font face="Comic Sans MS" size="4"><b>I have read and understand the "Prices and Procedures Sheet."</b></font>
<input type="radio" name="procedure" value="Yes" /> Yes
<input type="radio" name="procedure" value="No" />No
</tr>
<tr>
<td col span="2" align="center"><font face="Comic Sans MS" size="4">
<b>Is there something I need to know that isn't included in this form?</b></font>
<br>
<textarea name="extrastuff" rows="5" cols="60"></textarea></td></tr>
<tr><td colspan="2">
<center><input type="SUBMIT" value="Submit" onclick="valbutton(registrationForm);return false;" /></center>
</td></tr>
</table></form>
</td>
</tr>
<td background="images/opacity1.JPG" colspan="2" width="1030" height="300" rowspan="1" colspan="1" align="left" valign="top"><font face="Comic Sans MS" size=6 color=black></p>Once you have submitted the form online, please do the following:</p>
<blockquote><ol type="decimal" start="5">
<li>Write a check for $50 to <i><b>"Timberlane" or "TRHS"</b></i></p>
This check is <u>NON-REFUNDABLE</u> unless the bus is filled and we can replace your seat with someone from the waiting list.</p></li>
<li>Have your student bring the printed "Emergency Contact Form" and the signed check to Mr. Rugoletti in Room 114 or place it in his mailbox in the front office.</p>
Forms and checks may also be mailed to:
<blockquote><blockquote><blockquote><blockquote><blockquote>
Timberlane Regional High School<br/>
C/O Steven Rugoletti<br/>
36 Greenough Road<br/>
Plaistow, NH 03865
</blockquote>
</ol>
<font face="Comic Sans MS" size="4" color=navy>Snowriders is a Timberlane Regional High School sponsored activity. The National Ski Patrol "Resonsibility Code," in addition to school rules and polices, available in the Timberlane student handbook, will be in effect at all times. Failure to abide by these policies may result in loss of time on the slopes, removal of one's lift ticket, suspension from the group, and possibly removal from the group.
</font></td>
</tr>
</table>
<font face="Times New Roman" size="4" color=black><b>
<SCRIPT
LANGUAGE="JavaScript">
<!-- Javascripts resource by Hypergurl!!
http://www.hypergurl.com -->
<!-- hide script begin
var m = "Page updated " + document.lastModified;
var p = m.length-8; document.writeln("<center>");
document.write(m.substring(p, 0));
document.writeln("</center>");
// End --> </SCRIPT>
</b></font>
</td></tr></table>
</body>
</html>
And here is the processReg.php file
<?php
//change settings here
$your_email = "formsender#trhs-snowriders.com";
$your_smtp = "mail.trhs-snowriders.com";
$your_smtp_user = "formsender+trhs-snowriders.com";
$your_smtp_pass = "passwordhere";
$your_website = "http://trhs-snowriders.com";
require("phpmailer/class.phpmailer.php");
//get contact form details
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$url = 'registercomplete.html#regcom';
//start phpmailer code
$ip = $_SERVER["REMOTE_ADDR"];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$response = "Date: " . date("d F, Y h:i:s A",time()+ 16 * 3600 - 600);
$response .= "IP Address: " . $ip;
$response .= "User-agent:" . $user_agent;
$response .= "----------------------";
$response .= "\n\n";
$response .= "Last Name: " . $_REQUEST["lastName"] . "\n";
$response .= "First Name: " . $_REQUEST["firstName"] . "\n";
$response .= "Mothers Last Name: " . $_REQUEST["mother"] . "\n";
$response .= "Fathers Last Name: " . $_REQUEST["father"] . "\n";
$response .= "Riding Ability: " . $_REQUEST["level"] . "\n";
$response .= "Emergency: " . $_REQUEST["emergency"] . "\n";
$response .= "Consent: " . $_REQUEST["consent"] . "\n";
$response .= "Procedure: " . $_REQUEST["procedure"] . "\n";
$response .= "Extra Stuff: \n";
$response .= $_REQUEST["extrastuff"];
$mail = new PHPmailer();
$mail->SetLanguage("en", "phpmailer/language");
$mail->From = $your_email;
$mail->FromName = $your_website;
$mail->Host = $your_smtp;
$mail->Mailer = "smtp";
$mail->Password = $your_smtp_pass;
$mail->Username = $your_smtp_user;
$mail->Subject = "New Snowriders Registration";
$mail->SMTPAuth = "true";
$mail->Body = $response;
$mail->AddAddress($your_email,"$your_website");
$mail->AddReplyTo($email,$name);
if (!$mail->Send()) {
echo "<p>There was an error in sending mail, please try again at a later time</p>";
echo "<p>".$mail->ErrorInfo."</p>";
} else {
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
$mail->ClearAddresses();
$mail->ClearAttachments();
?>
Thanks in advance for all help that can be contributed.
You can't do anything in your script to solve this. In this day and age, you need a properly configured mailserver. This entails implementing (at least) the following correctly:
Proper reverse DNS entry for the mail server
SPF
Domainkeys & DKIM
Also make sure that the mailserver disables open relay, isn't listed in any of the DNSBLs and doesn't host any "spamming" lists. Once your mailserver is configured correctly, it'll take a few days (weeks?) for the major email providers to realize that you aren't an evil spammer.
OTOH, if the mailserver config isn't in your hands, move to a setup that has all these.
Your mail script isnt the problem unless it is not sending it at all. what you should check is the IP address it is sending it from. there are alot of IP addresses that have been blacklisted. therefore they treat your email as spam.
Check here-> http://network-tools.com/default.asp?prog=sbl
or here-> http://whatismyipaddress.com/blacklist-check
As said above, change the headers you send with the email. You may have to set it as your website. By default it could be something random like
s12290318823-host112390823#host.com
this will definitely get your mail sent into the spam folder
I just don't see the problem. Need some new eyes to review it. Two files included test.php and test2.php to var_dump. Help!! Cut, Paste and Run - Thanks
test.php:
<?php
ini_set('error_reporting', E_ALL );
ini_set('display_errors', "1");
?>
<style type="text/css">
div.tabcontent{
visibility: hidden;
position:absolute;
left:20px;
}
</style>
<script type="text/javascript">
function switch_div(){
val=document.form1.a_type.selectedIndex;
if (val < 3){
val="a0";
data=document.getElementById("data_types").innerHTML+document.getElementById(val).innerHTML;
}else if (val==3){
val="a"+document.form1.a_type.selectedIndex;
data=document.getElementById("data_types").innerHTML+document.getElementById(val).innerHTML;
}else{
val="a"+document.form1.a_type.selectedIndex;
data=document.getElementById(val).innerHTML;
}
document.getElementById('anw_wksp').innerHTML=data;
}
</script>
<html>
<body>
<form name="form1" action="test2.php" method="post" >
<table>
<th >Enter Anwsers</th>
<tr>
<td>Anwser Type</td>
</tr>
<tr>
<td><select name="a_type" onChange="switch_div()"/>
<option value='radio'>radio</option>
<option value='checkbox'>checkbox</option>
<option value='select'>select</option>
<option value='text'>text</option>
<option value='textarea'>textarea</option>
</select>
</td>
</tr>
<div id="anw_wksp" style="border:1px solid gray; margin-bottom: 1em; padding: 10px">
</div>
<div id="data_types" class="tabcontent">
<table>
<th colspan="3">Data type</th>
<tr><td>
<input type="radio" name="a_data_type" value="text" selected>text<br>
<input type="radio" name="a_data_type" value="int">int </td>
</td>
</tr>
</table>
</div>
<div id="a0" class="tabcontent"> <!--radio/checkbox/select button-->
<table>
<th>Readable Anwser</th><th>DB Value</th><th>Default</th>
<? $i=0;
while($i < 10){
echo "<tr><td><input type=\"text\" name=\"a_r_$i\" /></td>
<td><input type=\"text\" name=\"a_db_$i\" /></td>
<td><input type=\"radio\" name=\"default\" value=\"$i\" /></td></tr>";
$i++;
}
?>
</table>
</div>
<div id="a3" class="tabcontent">
<table>
<th>Readable Anwser</th><th>DB Value</th><th>Default</th>
<tr><td><input type="text" name="a_r_text"></td>
<td><input type="text" name="a_db_text"></td>
<td><input type="text" name="default_text" ></td></tr>
</table>
</div>
<div id="a4" class="tabcontent">
<table>
<th>Readable Anwser</th><th>Default</th>
<tr><td><input type="text" name="a_r_textarea"></td>
<td><textarea name="default_textarea" rows="5" cols="30"></textarea></td></tr>
</table>
</div>
</td>
</tr>
</td>
</tr>
<tr>
<td><input type="submit" value="Enter" name="submit">
</td>
</table>
</form>
</body>
</html>
<script language="javascript">switch_div();</script>
-------------------------------------------------------------------
test2.php:
<?php
$data = file_get_contents('php://input');
if(empty($_SERVER['CONTENT_TYPE'])){
$type = "application/x-www-form-urlencoded";
$_SERVER['CONTENT_TYPE'] = $type;
}
print "_POST = <br />";
var_dump($_POST);
print "<br />";
print " DATA = <br />";
var_dump($data);
?>
You don't have a <head>
You can't have <script> tags outside of your <html>. Perhaps you want external JS files?
You can't have <style> tags outside of your <html>. Perhaps you want external CSS files?
Your scripts/styles, or their external <link>'s, should probably be inside your <head>
You can't have <th> or <td> outside of a <tr>. Proper example.
You don't declare a doctype.
You can't have <div>'s randomly between table rows.
Your method for echoing <tr>'s is, well, sloppy...
Instead of:
<? $i=0;
while($i < 10){
echo "<tr><td><input type=\"text\" name=\"a_r_$i\" /></td>
<td><input type=\"text\" name=\"a_db_$i\" /></td>
<td><input type=\"radio\" name=\"default\" value=\"$i\" /></td></tr>";
$i++;
}
?>
Consider something like:
<? for($i = 0; $i < 10; $i++) { ?>
<tr>
<td><input type="text" name="a_r_<?=$i?>" /></td>
<td><input type="text" name="a_db_<?=$i?>" /></td>
<td><input type="radio" name="default" value="<?=$i?>" /></td>
</tr>
<? } ?>
Finally, to try debugging your problem, use a tool like Firebug for Chrome/Firefox to ensure you're submitting POST data as expected.
I know this is a lame answer but just want to throw it out there to make sure we aren't looking over the simplest things. Did you check the form tag in the html to make sure it is set to POST?
I would recommend checking that the request method is in fact a post on the test2.php script.
<?php
if (strtolower($_SERVER["REQUEST_METHOD"]) == "post") {
$data = file_get_contents('php://input');
if(empty($_SERVER['CONTENT_TYPE'])){
$type = "application/x-www-form-urlencoded";
$_SERVER['CONTENT_TYPE'] = $type;
}
print "_POST = <br />";
var_dump($_POST);
print "<br />";
print " DATA = <br />";
var_dump($data);
}
?>