alguien a programado un foro? en php
| From: | maite maite | Date: | Thu, 01 May 2003 23:59:31 +0000 |
| Subject: | alguien a programado un foro? en php | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-35745@lists.php.net to get a copy of this message | ||
miren -> necesito saber si alguien ha programado un foro con php+mysql -> ahora no puedo hacer
las pruebas porq tengo problemas con mysql
alguien podria ver si mi codigo cumple bien la funcion de foro, porfa ayudenme !!!
fororesult.php
<?
require "comienzo.html";
$host="localhost";
$user="nona";
$pwd="nona";
$db="forodb";
$tabla="mensajes";
$link=mysql_connect($host,$user,$pwd) or die ("No me pueo conectar... mata al tarro!!!");
$queryInsert="INSERT INTO $tabla VALUES
('$_POST['nombre']','$_POST['universidad']',
'$_POST['carrera']','$_POST['curso']',
'$_POST['subject']','$_POST['mensaje']')";
mysql_db_query($db,$queryInsert,$link);
print("<table border=0 width=80% cellpadding=2 cellspacing=2>\n");
print("<tr>\n");
print("<td>Nombre</td>\n");
print("<td>Carrera</td>\n");
print("<td>Curso</td>\n");
print("<td>Universidad</td>\n");
print("<td>Subject</td>\n");
print("<td>Mensaje</td>\n");
$query="SELECT * FROM $tabla";
$Result=mysql_db_query($db,$query,$link);
while($S=mysql_fetch_array($Result))
{
print("<tr>\n");
print("<td>$S[nombre]</td>");
print("<td>$S[carrera]</td>");
print("<td>$S[curso]</td>");
print("<td>$S[universidad]</td>");
print("<td>$S[subject]</td>");
print("<td>$S[mensaje]</td>");
print("</tr>");
}
print("</table>");
mysql_close($link);
?>
<body>
</body>
</html>
----------------------------------------------------------
tablaforo.php
<html>
<head><title>danos tu opinion...</title>
<style type="text/css">
body,center {
color : #000000;
font-family : Verdana;
font-size : 11px;
scrollbar-face-color : #dee3e7;
scrollbar-highlight-color : #ffffff;
scrollbar-shadow-color : #dee3e7;
scrollbar-3dlight-color : #d1d7dc;
scrollbar-arrow-color : #006699;
scrollbar-track-color : #efefef;
scrollbar-darkshadow-color : #98aab1;
}
a:link { font-size : 11px; font-family : Verdana; color : #0050d0; text-decoration : none; }
a:visited { font-size : 11px; font-family : Verdana; color : #0050d0; text-decoration : none; }
a:active { font-size : 11px; font-family : Verdana; color : #0050d0; text-decoration : none; }
a:hover { font-size : 11px; font-family : Verdana; color : #999999; text-decoration : underline;
}
table,td,tr { font-size : 9px; color : #fffff0; }
</style>
<script language="JavaScript">
<!--
var defaultEmptyOK = false
// listas de caracteres
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyzáéíóúñü"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚÑ"
//var caracteresRaros = "):(^[.]{+}Ç`_-/&%$·"!ªº?¿'¡*;,<|@#";
var whitespace = " \t\n\r";
var mMessage = "Error: no puede dejar este espacio vacio"
var pPrompt = "Error: ";
var pAlphanumeric = "ingrese un texto que contenga solo letras y/o numeros";
var pAlphabetic = "ingrese un texto que contenga solo letras";
var pInteger = "ingrese un numero entero";
var pNumber = "ingrese un numero";
var pEmail = "ingrese una dirección de correo electrónico válida";
//var pRaros ="ingresa otro caracter !!!";
function makeArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 0
}
return this
}
// s es vacio
function isEmpty(s)
{ return ((s == null) || (s.length == 0))
}
// s es vacio o solo caracteres de espacio
function isWhitespace (s)
{ var i;
if (isEmpty(s)) return true;
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
// si el caracter en que estoy no aparece en whitespace,
// entonces retornar falso
if (whitespace.indexOf(c) == -1) return false;
}
return true;
}
// Quita todos los caracteres que que estan en "bag" del string "s" s.
function stripCharsInBag (s, bag)
{ var i;
var returnString = "";
// Buscar por el string, si el caracter no esta en "bag",
// agregarlo a returnString
for (i = 0; i < s.length; i++)
{ var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
// Lo contrario, quitar todos los caracteres que no estan en "bag" de "s"
function stripCharsNotInBag (s, bag)
{ var i;
var returnString = "";
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (bag.indexOf(c) != -1) returnString += c;
}
return returnString;
}
// Quitar todos los espacios en blanco de un string
function stripWhitespace (s)
{ return stripCharsInBag (s, whitespace)
}
// La rutina siguiente es para cubrir un bug en Netscape
function charInString (c, s)
{ for (i = 0; i < s.length; i++)
{ if (s.charAt(i) == c) return true;
}
return false
}
// Quita todos los espacios que antecedan al string
function stripInitialWhitespace (s)
{ var i = 0;
while ((i < s.length) && charInString (s.charAt(i), whitespace))
i++;
return s.substring (i, s.length);
}
// c es una letra del alfabeto espanol
function isLetter (c)
{
return( ( uppercaseLetters.indexOf( c ) != -1 ) ||
( lowercaseLetters.indexOf( c ) != -1 ) )
}
// c es un digito
function isDigit (c)
{ return ((c >= "0") && (c <= "9"))
}
// c es letra o digito
function isLetterOrDigit (c)
{ return (isLetter(c) || isDigit(c))
}
// c es un caracter raro
//function isCaracteresR (c)
//{ return ( ( uppercaseLetters.indexOf( c ) !=-1 ) ||
// ( lowercaseLetters.indexOf( c ) != -1 ) ||
// ( caracteresRaros.indexOf( c ) != -1 )
// )
//}
// ---------------------------------------------------------------------- //
// NUMEROS //
// ---------------------------------------------------------------------- //
// s es un numero entero (con o sin signo)
function isInteger (s)
{ var i;
if (isEmpty(s))
if (isInteger.arguments.length == 1) return defaultEmptyOK;
else return (isInteger.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if( i != 0 ) {
if (!isDigit(c)) return false;
} else {
if (!isDigit(c) && (c != "-") || (c == "+")) return false;
}
}
return true;
}
// s es un numero (entero o flotante, con o sin signo)
function isNumber (s)
{ var i;
var dotAppeared;
dotAppeared = false;
if (isEmpty(s))
if (isNumber.arguments.length == 1) return defaultEmptyOK;
else return (isNumber.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if( i != 0 ) {
if ( c == "." ) {
if( !dotAppeared )
dotAppeared = true;
else
return false;
} else
if (!isDigit(c)) return false;
} else {
if ( c == "." ) {
if( !dotAppeared )
dotAppeared = true;
else
return false;
} else
if (!isDigit(c) && (c != "-") || (c == "+")) return
false;
}
}
return true;
}
// ---------------------------------------------------------------------- //
// STRINGS SIMPLES //
// ---------------------------------------------------------------------- //
// s tiene solo letras
function isAlphabetic (s)
{ var i;
if (isEmpty(s))
if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
else return (isAlphabetic.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
// Check that current character is letter.
var c = s.charAt(i);
if (!isLetter(c))
return false;
}
return true;
}
// s tiene solo letras y numeros
function isAlphanumeric (s)
{ var i;
if (isEmpty(s))
if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
else return (isAlphanumeric.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (! (isLetter(c) || isDigit(c) ) )
return false;
}
return true;
}
// s tiene solo letras y numeros
//function isCaracteresRaros (s)
//{ var i;
//
// if (isEmpty(s))
// if (isCaracteresRaros.arguments.length == 1) return defaultEmptyOK;
// else return (isCaracteresRaros.arguments[1] == true);
//
// for (i = 0; i < s.length; i++)
// {
// var c = s.charAt(i);
// if (! (isLetter(c) || isDigit(c) || isCaracteresR(c) ) )
// return false;
// }
//
// return true;
//}
// s tiene solo letras, numeros o espacios en blanco
function isName (s)
{
if (isEmpty(s))
if (isName.arguments.length == 1) return defaultEmptyOK;
else return (isAlphanumeric.arguments[1] == true);
return( isAlphanumeric( stripCharsInBag( s, whitespace ) ) );
}
// ---------------------------------------------------------------------- //
// EMAIL //
// ---------------------------------------------------------------------- //
// s es una direccion de correo valida
function isEmail (s)
{
if (isEmpty(s))
if (isEmail.arguments.length == 1) return defaultEmptyOK;
else return (isEmail.arguments[1] == true);
if (isWhitespace(s)) return false;
var i = 1;
var sLength = s.length;
while ((i < sLength) && (s.charAt(i) != "@"))
{ i++
}
if ((i >= sLength) || (s.charAt(i) != "@")) return false;
else i += 2;
while ((i < sLength) && (s.charAt(i) != "."))
{ i++
}
if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
else return true;
}
// ---------------------------------------------------------------------- //
// FUNCIONES PARA RECLAMARLE AL USUARIO //
// ---------------------------------------------------------------------- //
// pone el string s en la barra de estado
function statBar (s)
{ window.status = s
}
// notificar que el campo theField esta vacio
function warnEmpty (theField)
{ theField.focus()
alert(mMessage)
statBar(mMessage)
return false
}
// notificar que el campo theField es invalido
function warnInvalid (theField, s)
{ theField.focus()
theField.select()
alert(s)
statBar(pPrompt + s)
return false
}
// el corazon de todo: checkField
function checkField (theField, theFunction, emptyOK, s)
{
var msg;
if (checkField.arguments.length < 3) emptyOK = defaultEmptyOK;
if (checkField.arguments.length == 4) {
msg = s;
} else {
if( theFunction == isAlphabetic ) msg = pAlphabetic;
if( theFunction == isAlphanumeric ) msg = pAlphanumeric;
if( theFunction == isInteger ) msg = pInteger;
if( theFunction == isNumber ) msg = pNumber;
if( theFunction == isEmail ) msg = pEmail;
if( theFunction == isName ) msg = pName;
// if( theFunction == isCaracteresRaros ) msg = pRaros;
}
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
if ((emptyOK == false) && (isEmpty(theField.value)))
return warnEmpty(theField);
if (theFunction(theField.value) == true)
return true;
else
return warnInvalid(theField,msg);
}
-->
</script>
</head>
<body bgcolor="#000000">
<script>
function Verificar () {
if( checkField( document.formaforo.nombre, isAlphanumeric, false ) &&
checkField( document.formaforo.subject, isAlphanumeric, false ) &&
// checkField( document.formaforo.mensaje, isAlphanumeric, false ) &&
//checkField( document.forma1.nombres_afiliado, isAlphabetic, false ) &&
//checkField( document.forma1.s1_cuatro, isAlphabetic, false ) &&
//checkField( document.forma1.s2_cuatro, isAlphabetic, false ) &&
//checkField( document.forma1.s3_mes, isAlphabetic, false ) &&
//checkField( document.forma1.s4_cuatro, isAlphabetic, false ) &&
//checkField( document.forma1.s5_cuatro, isAlphabetic, false ) &&
//checkField( document.forma1.comuna, isAlphabetic, false ) &&
//checkField( document.forma1.ciudad, isAlphabetic, false ) &&
//checkField( document.forma1.s3_dia, isInteger, false ) &&
//checkField( document.forma1.s3_ano, isInteger, false ) &&
//checkField( document.forma1.direccion, isAlphanumeric, false )
//&& checkField( document.forma1.telefono, isNumber, false ) &&
checkField( document.formaforo.campoE, isEmail, false )
)
document.formaforo.submit();
};
</script>
<form name="formaforo" action="fororesult.php" method=post>
<table border=0 cellpadding=0 cellspacing=0 width=50% bgcolor="#000000">
<tr>
<td>
<table border=0 cellpadding=2 cellspacing=2 bgcolor="#ffffff" width=70%>
<tr><td></td><td></td></tr>
<tr><td width=70><font color="#000000">Nombre: </font></td>
<td width=50><input name="nombre" type=text>
</tr>
<tr>
<td><font color="#000000">Universidad: </font></td>
<td><select name="universidad">
<option value="UV">Universidad de Valparaíso</option>
<option value="UTFSM">UTFSM</option>
<option value="UCV">Pontificia Universidad Católica de
Valparaíso</option>
</td>
</tr>
<tr>
<td><font color="#000000">Carrera: </font></td>
<td><select name="carrera">
<option value="informatica">Informática</option>
<option value="electronica">Electrónica</option>
<option value="plan comun">Plan Común</option>
</td>
</tr>
<tr>
<td><font color="#000000">Curso: </font></td>
<td><select name="curso">
<option value="Mechón">1º año</option>
<option value="Segundo">2º año</option>
<option value="Tercero">3º año</option>
<option value="Cuarto">4º año</option>
<option value="Quinto">5º año</option>
<option value="Sexto">6º año</option>
</td>
</tr>
<tr></tr>
<tr>
<td><font color="#000000">Subject: </font></td>
<td><input name="subject" type=text></td>
</tr>
<tr>
<td><font color="#000000">Mensaje: </font></td>
<td><textarea name="mensaje" rows=8 cols=40></textarea></td>
</tr>
</table>
<td></tr>
<tr>
<td bgcolor="#000000">
<left>
<input type="reset" value="Limpiar">
<input type=button value="Enviar>>>" onClick=Verificar()>
</left></td>
<td bgcolor="#000000"></td>
</tr>
</table>
</form>
</body>
</html>
--
____________________________________________________
Get your own Hello Kitty email @ www.sanriotown.com
Powered by Outblaze