mira este ejemplo a ver si te sirve de algo... es un poco extenso pero a mi me sirvio de mucho....
Código PHP:
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor="DimGray" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr valign="top" align="center">
<td><table width="659" border="0" cellspacing="0" cellpadding="0">
<tr height="600"><td align="center" valign="top" width="649" height="600">
<?php
require ("config.php");
#>--------------------------------------------------------------------------------------------------------- FUNCION HACER NUEVO POST -------------------------------------------------------------------------------
if (!isset($_GET['accion'])){
echo <<< HTML
<br><br><form method="post" action="$PHP_SELF?accion=hacernuevo">
<table width="350" border="1" cellspacing="0" cellpadding="0" bordercolor="DarkGray" align="center">
<tr>
<td colspan="2" height="16" bgcolor="DimGray">
<div align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"">.:
Registrar Nuevo Post :.</font></b></div>
</td>
</tr>
<tr bgcolor="Gray">
<td width="158">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nick Name
: </font></div>
</td>
<td width="170"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="nick" class="botones3" maxlength="16">
</font></b></td>
</tr>
<tr bgcolor="Gray">
<td width="158">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Password
: </font></div>
</td>
<td width="170"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="password" name="password1" class="botones3" maxlength="15">
</font></b></td>
</tr>
<tr bgcolor="Gray">
<td width="158">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Password Repitalo : </font></div>
</td>
<td width="170"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="password" name="password2" class="botones3" maxlength="15">
</font></b></td>
</tr>
<tr bgcolor="Gray">
<td width="158">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nombre Personal : </font></div>
</td>
<td width="170"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="nombre" class="botones3" size="20" maxlength="20">
</font></b></td>
</tr>
<tr bgcolor="Gray">
<td width="158">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Email Valido: </font></div>
</td>
<td width="170"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="email" class="botones3" size="20" maxlength="100">
</font></b></td>
</tr>
<tr bgcolor="Gray">
<td width="158">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">File / Url Name : </font></div>
</td>
<td width="170"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="postname" value="ejem: Adobe Phot..." class="botones3" size="20" maxlength="120">
</font></b></td>
</tr>
</tr>
<tr bgcolor="Gray">
<td width="158">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Direccion Url : </font></div>
</td>
<td width="170"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="posturl" value="http://" class="botones3" size="20" maxlength="255">
</font></b></td>
</tr>
<tr bgcolor="Gray">
<td width="158">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Categoria : </font></div>
</td>
<td width="170"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<select name="postcategoria" class="botones3" size="1">
<option value="APPZ">APPZ</option>
<option value="GAMEZ">GAMEZ</option>
<option value="MP3">MP3</option>
<option value="SCRIPT">SCRIPT</option>
<option value="URL">URL</option>
<option value="DIVX">DIVX</option>
<option value="MANUAL">MANUAL</option>
</select></font></b></td>
</tr>
<tr bgcolor="Gray">
<td colspan="2" height="40">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Breve Descripcion</font>
<textarea rows=7 cols=39 class="botones3" name="postdescription"></textarea></div>
</font></b>
</div>
</td>
</tr>
<tr bgcolor="DimGray">
<td colspan="2" height="40">
<div align="center"><br>
<input type="submit" name="Submit" value=" Registrar " class="botones" ><br><br>
<input type="button" value=" Borrar " onclick="window.location.reload()" class="botones2"><br><br>
</div>
</td>
</tr>
</table>
</form>
HTML;
}
#>----------------------------------------------------------------------------------------------------------- HACER NUEVO USER --------------------------------------------------------------------------------------
if ($_GET['accion']=="hacernuevo"){
$nick=$_POST['nick'];
$pass1=$_POST['password1'];
$pass2=$_POST['password2'];
$nombre=$_POST['nombre'];
$email=$_POST['email'];
$postname=$_POST['postname'];
$postdate= date("d/m");
$postdescription=$_POST['postdescription'];
$posturl=$_POST['posturl'];
$postcategoria=$_POST['postcategoria'];
$postip=$REMOTE_ADDR;
$nivel_acceso= "2";
$dls= "0";
//---------------------------- comprobar URL si existe ----------------------------\\
function url($url)//Se le pasa la url
{
$fp=@fopen($url,"r");//Utilizamos fopen para abrir esa url
if($fp){//Si fopen abre la url
return true;
}else{//si no devuelve false
return false;
}
@fclose($fp);//Cerramos la conexion
}
$existe=url("$posturl");
if($existe){
}else{
echo <<< HTML
$error5 <input type="button" value="Volver" onclick="history.back()" class="botones2">
HTML;
exit;
}
//---------------------------- comprobar URL si existe ----------------------------\\
if ($nick=="" or $pass1=="" or $pass2=="" or $nombre=="" or $email=="" or $postname=="" or $postdate=="" or $postdescription=="" or $posturl=="" or $postcategoria=="" or $postip=="" or $nivel_acceso=="" or $dls=="") {
echo <<< HTML
$error2 <input type="button" value="Volver" onclick="history.back()" class="botones2">
HTML;
exit;
}
if ($pass1 != $pass2){
echo <<< HTML
$error3 <input type="button" value="Volver" onclick="history.back()" class="botones2">
HTML;
exit;
}
$usuarios_consulta = mysql_query("SELECT id FROM $sql_tabla WHERE nick='$nick'") or die(mysql_error());
$total_encontrados = mysql_num_rows ($usuarios_consulta);
mysql_free_result($usuarios_consulta);
if ($total_encontrados != 0) {
echo <<< HTML
$error4 <input type="button" value="Volver" onclick="history.back()" class="botones2">
HTML;
exit;
}
$usuario=stripslashes($usuario);
$pass1 = md5($pass1);
mysql_query("INSERT INTO $sql_tabla values('','$nick','$pass1','$nombre','$email','$postname','$postdate','$postdescription','$posturl','$postcategoria','$postip','$nivel_acceso','$dls')") or die(mysql_error());
mysql_close();
echo <<< HTML
$pnewok<input type="button" name="buttonName" class="botones2" value=Home onClick="window.open('home.php','home')"><META HTTP-EQUIV="Refresh" CONTENT="5;URL=home.php"></a></button>
HTML;
exit;
}
?>