perdon el codigo que me falla es este
Código PHP:
ob_start();
require("config.php");
require("global.php");
require("header.php");
if ($config['recaptcha']) {
require("recaptchalib.php");
}
$error = false;
$url = trim(urldecode(@$_REQUEST['url']));
$nom_sugest = trim(@$_REQUEST['nom_sugest']);
if ($config['recaptcha']) {
$response = recaptcha_check_answer($config['recaptcha_privatekey'], $_SERVER['REMOTE_ADDR'], @$_POST['recaptcha_challenge_field'], @$_POST['recaptcha_response_field']);
if (!$response->is_valid) {
$error = true;
echo "<div class=\"ErrorBody\">El codigo de seguridad no es correcto, prueba otra vez.</div><br />\n";
}
else if ($response->error) {
$error = true;
echo "<div class=\"ErrorBody\">reCAPTCHA caused an error: {$response->error}</div><br />\n";
}
}
else if ($config['captcha']) {
session_start();
if (!$_SESSION['captcha_phrase'] || $_SESSION['captcha_phrase'] != @$_POST['captcha']) {
$error = true;
echo "<div class=\"ErrorBody\">El codigo de seguridad no es correcto, prueba otra vez.</div><br />\n";
}
}
if (!empty($url) && !empty($nom_sugest) && !$error) {
if ($url{strlen($url) - 1} == "/") {
$url = substr($url, 0, -1);
}
if (!preg_match("/^(ht|f)t(p|ps)\:\/\//si", $url)) {
$url = "http://".$url;
}
$length = strlen($url);
$count = 0;
db_connect();
do {
$short_url_1 = str_replace (" ", "%20", $nom_sugest);
$short_url = "_".$short_url_1;
/*$suffix = $short_url{0};*/
$result = mysql_query("SELECT url, short_url FROM url_sugest WHERE short_url = '$short_url'") or die(mysql_error());
$count = mysql_num_rows($result);
if ($count > 0) {
$row = mysql_fetch_row($result);
if (stripslashes($row[0]) == $url) {
break;
}
}
else {
mysql_query("INSERT INTO url_sugest (short_url, url, created) VALUES ('$short_url', '".mysql_real_escape_string($url)."', NOW())") or die(mysql_error());
break;
}
} while ($count > 0);
$short_url = "http://".$config['domain']."/".((!$config['rewrite']) ? "?" : "").$short_url;
$short_length = strlen($short_url);
$short_url_sense = str_replace ("%20", " ", $short_url);
echo "<div class=\"ResultTitle\"><strong>URL exprimida!</strong></div><br />\n".
"<div class=\"ResultBody\">La URL que puedes mostrar:<br /><br />\n".
"<strong>$url</strong><br /><br />\n".
"tiene una longitud de $length caracteres y dio lugar a la siguiente dirección URL abreviada que tiene una longitud de $short_length caracteres:<br /><br />\n".
"<strong>$short_url_sense</strong><br /><br />\n".
"[ <a href=\"$short_url_sense\" target=\"_blank\">Abrir en una nueva ventana</a> ]</div>\n";
}
else {
echo "<div class=\"ErrorBody\"><strong>La Dirección corta ya esta en uso prueba con otra!!!!.</strong></div><br />\n";
}
if ($config['captcha']) {
mt_srand((double) microtime() * 1000000);
$_SESSION['captcha_phrase'] = substr(strtoupper(md5(mt_rand())), 0, 6);
session_write_close();
}
?>
<style type="text/css">
<!--
.Estilo1 {
color: #FF0000;
font-weight: bold;
}
-->
</style>
<br /><br /><br />
<form method="post" action="create.php">
<div class="FormBody">
<strong>Entra la URL a reducir:</strong><br />
<input type="text" name="url" size="80" />
<br />
<br /><br /><br />
<?php
if ($config['recaptcha']) {
echo recaptcha_get_html($config['recaptcha_publickey']);
}
else if ($config['captcha']) {
echo "<strong>Codigo de Seguridad:</strong><br />\n".
"<img src=\"captcha.php\" alt=\"\"/> <input type=\"text\" name=\"captcha\" size=\"10\" /><br />\n";
}
?>
<input type="submit" value="Reducir" />
</div>
</form>
<form method="post" action="create2.php">
<div id="nuevo_serv">
Nuevo Servício
<span class="Estilo1">BETA</span><br />
Ahora puedes poner tu la dirección!!!
<strong><br />
Entra la URL a reducir:</strong><br />
<input type="text" name="url" size="80" />
<br />
<br />
<?php
if ($config['recaptcha']) {
echo recaptcha_get_html($config['recaptcha_publickey']);
}
else if ($config['captcha']) {
echo "<strong>Codigo de Seguridad:</strong><br />\n".
"<img src=\"captcha.php\" alt=\"\"/> <input type=\"text\" name=\"captcha\" size=\"10\" /><br />\n";
}
?>
<br />
<strong>Nombre que deseas...</strong><br />
<input type="text" name="nom_sugest" size="20" id="nom_sugest" />
<em><br />
</em><br />
<input type="submit" value="Reducir" />
</div>
</form>
<br />
<br />
<?php
require("footer.php");
ob_end_flush();
y lo que hace es en el segundo form (ya que el primero va a create.php)
es le envio una URL mas un nom_sugest
me mira en la tabla url_sugest si en nombre sugest existe si no existe lo da de alta si existe ma lanza el error "que ya existe el nombre sugerido"