adding html to php or something like that

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
shoyle
Forum Newbie
Posts: 21
Joined: Fri Jun 19, 2009 11:01 pm

adding html to php or something like that

Post by shoyle »

Hi, I allways receive good answers from this forum so I hope it happens again :D so after the thanks to all the ones who spend time helping dummies like me, i got this cuestion:

I got this html contact page:

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="shortcut icon" href="http://www.laradialautomoviles.com/favicon.gif">
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>.: La Radial Automoviles - Contacto :.</title>
<style type="text/css">
<!--
body {
    background-image: url(images/rayas.gif);
    background-color: #FFFFFF;
}
.Estilo13 {font-family: Calibri; color: #333333; }
.Estilo7 {font-family: Calibri; color: #FFFFFF; }
.Estilo11 {
    color: #27A7E4;
    font-weight: bold;
    font-family: Calibri;
    font-size: 24px;
}
 
a:link {
    color: #15BCFB;
    text-decoration: none;
}
a:visited {
    color: #0679B0;
    text-decoration: none;
}
a:hover {
    color: #2495F0;
    text-decoration: none;
}
a:active {
    color: #666666;
    text-decoration: none;
}
.Estilo20 {font-family: Calibri; color: #FFFFFF; font-weight: bold; }
.Estilo21 {font-family: Calibri}
.Estilo22 {color: #FFFFFF}
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
 
<body onload="MM_preloadImages('images/larradial_08.gif','images/larradial_09.gif','images/larradial_10.gif','images/larradial_11.gif','images/larradial_12.gif','images/la-BUENA-2_06.gif','images/la-BUENA-2_07.gif','images/la-BUENA-2_08.gif','images/la-BUENA-2_09.gif','images/la-BUENA-2_10.gif')" topmargin="0">
<table width="200" border="0" align="center" cellpadding="0" cellspacing="0" background="images/rayas.gif">
  <tr>
    <td height="89"><img src="images/la-BUENA_03.gif" width="763" height="196" /></td>
  </tr>
  <tr>
    <td height="272"><script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','763','height','272','src','slide','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','slide' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="763" height="272">
      <param name="movie" value="slide.swf" />
      <param name="quality" value="high" />
      <embed src="slide.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="763" height="272"></embed>
    </object></noscript></td>
  </tr>
  <tr>
     <td height="37"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','images/la-BUENA-2_06.gif',1)"><img src="images/la-BUENA_06.gif" name="Image2" width="101" height="72" border="0" id="Image2" /></a><a href="vehiculos-nuevos.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','images/la-BUENA-2_07.gif',1)"><img src="images/la-BUENA_07.gif" name="Image3" width="192" height="72" border="0" id="Image3" /></a><a href="vehiculos-usados.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images/la-BUENA-2_08.gif',1)"><img src="images/la-BUENA_08.gif" name="Image4" width="180" height="72" border="0" id="Image4" /></a><a href="nuestro-equipo.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','images/la-BUENA-2_09.gif',1)"><img src="images/la-BUENA_09.gif" name="Image5" width="171" height="72" border="0" id="Image5" /></a><a href="contacto.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','images/la-BUENA-2_10.gif',1)"><img src="images/la-BUENA_10.gif" name="Image6" width="119" height="72" border="0" id="Image6" /></a></td>
  </tr>
  <tr><td height="500" background="images/bak.gif"><table width="762" height="500" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td><table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><form action="enviar.php" method="post">
<div align="center">
<span class="Estilo21">Nombre:</span><br/>
  <input type="text" name="nombre" />
  <br/>
  <br/>
<span class="Estilo21">Tel&eacute;fono:</span><br/>
<input type="text" name="telefono" />
<br/>
<br/>
<span class="Estilo21">E-mail:</span><br/>
<input type="text" name="email" />
<br/>
<br/>
<span class="Estilo21">Mensaje:</span><br/>
<textarea rows="10" cols="50" name="mensaje"></textarea><br/>
<br/>
<input type="image" name="submit" src="images/enviar.gif" border="0" />   <!-- este codigo te puede servir    <input type="image" name="submit" src="submit.png" border="0" />   en caso de kerer usar una imagen diferente para el boton d enviar :D-->
</div></td></tr>
      </table></td>
    </tr>
  </table></td>
  </tr>
    <tr><td height="62"><a href="http://www.mysite.com"><img src="images/la-BUENA_13.gif" width="763" height="62" border="0"/></a></td>
  </tr>
</table>
 
 
</body>
 
</html>
 
 
and this php:

Code: Select all

 
<?php
 
//aca va el link a la pagina d gracias:D
header( 'Location: http://www.laradialautomoviles.com/gracias.html' ) ;
 
$nombre = $_POST['nombre'];
$telefono = $_POST['telefono'];
$mail = $_POST['email'];
 
//------------------------------------------------------//
 
 
if(!$mail == "" && (!strstr($mail,"@") || !strstr($mail,".")))
{
echo "<h2>Vuelva a la pagina anterior, ingrese una direccion de e-mail v&aacute;lida-.</h2>\n";
$badinput = "<h2>La informacion no fue ingresada.</h2>\n";
echo $badinput;
die ("Vuelva a la pagina anterior.");
}
//aca creo 1q dice: si los campos: visitante, mail de visitante, y nota estan vacios el resultado es: vuelva atraz rellene los campos vacios :D
if(empty($nombre) || empty($telefono) || empty($mail)) {
echo "<h2>Vuelva a la pagina anterior, rellene todas las casillas.</h2>\n";
die ("Vuelva a la pagina anterior.");
}
 
$pattern = '/[^0-9]/';
if (preg_match($pattern, $telefono)) {
echo "<h2>Vuelva a la pagina anterior, ingrese un numero de telefono valido.</h2>\n";
die ("Vuelva a la pagina anterior.");
    // $telefono contains invalid characters
}
 
 
if (empty($POST['mensaje'])) {
echo "<h2>Vuelva a la pagina anterior, rellene todas las casillas.</h2>\n";
die ("Vuelva a la pagina anterior.");
    // the user left the element empty
}
//--------------------------------------------------------------------------//
 
$header = 'From: ' . $mail . " rn";
 
 
$mensaje = "Este mensaje fue enviado por " . $nombre . " ";
$mensaje .= "Su telefono es: " . $telefono . " ";
$mensaje .= "Su e-mail es: " . $mail . " ";
$mensaje .= "Mensaje: " . $_POST['mensaje'] . " " ;
$mensaje .= "Enviado el " . date('d/m/Y', time());
 
//-----------------------------------------------------//
 
//----------------------------------------------------//
 
$para = 'admin@pumsho.com';
$asunto = 'Contacto desde pagina web';
 
mail($para, $asunto, utf8_decode($mensaje), $header);
 
echo 'Su mensaje ha sido enviado correctamente.';
?> 
 
 
now what I want is to have the php results displayed in an html similar to the one on top, so when they insert the write word to have a : thank you your mesage was sent, and when they do wrong: please fill all the information correctly , or something like that..


I'll be really thankfull!!!!
Last edited by califdon on Sun Jul 26, 2009 8:36 pm, edited 1 time in total.
Reason: Moderator corrected tags to display PHP and moved to appropriate forum.
shoyle
Forum Newbie
Posts: 21
Joined: Fri Jun 19, 2009 11:01 pm

Re: adding html to php or something like that

Post by shoyle »

Or at least when thy enter the rite information they get sent to a thank you page and when they dont they can see the errors like: use back fill all fields
Post Reply