InicioInfoCodigos PHP


PHP es un lenguaje de programación interpretado, diseñado originalmente para la creación de páginas web dinámicas. Es usado principalmente en interpretación del lado del servidor (server-side scripting) pero actualmente puede ser utilizado desde una interfaz de línea de comandos o en la creación de otros tipos de programas incluyendo aplicaciones con interfaz gráfica usando las bibliotecas Qt o GTK+.
PHP es un acrónimo recursivo que significa PHP Hypertext Pre-processor (inicialmente PHP Tools, o, Personal Home Page Tools). Fue creado originalmente por Rasmus Lerdorf en 1994; sin embargo la implementación principal de PHP es producida ahora por The PHP Group y sirve como el estándar de facto para PHP al no haber una especificación formal. Publicado bajo la PHP License, la Free Software Foundation considera esta licencia como software libre.


Codigos PHP Hechos Solo Copiar Y Pegar En Tu Web Mas Facil El Trabajo



1. JPG to ASCII Converter
2. Simple Image CAPTCHA
3. User Registration Form
4. Check If User Is Logged In





convertidor JPG a ASCII

Tome una imagen JPG, y convertirlo en código ASCII!
<html>
<head>
<title>Ascii</title>
<style>
body{
line-height:1px;
font-size:1px;
}
</style>
</head>
<body>
<?php
function getext($filename) {
$pos = strrpos($filename,'.');
$str = substr($filename, $pos);
return $str;
}
if(!isset($_POST['submit'])){
?>
<form action="<?echo $_SERVER['PHP_SELF'];?>" method="post">
JPG img URL: <input type="text" name="image">[br /]
<input type="submit" name="submit" value="Create">
</form>
<?
}else{
$image = $_POST['image'];
$ext = getext($image);
if($ext == ".jpg"{
$img = ImageCreateFromJpeg($image);
}
else{
echo'Wrong File Type';
}
$width = imagesx($img);
$height = imagesy($img);

for($h=0;$h<$height;$h++){
for($w=0;$w<=$width;$w++){
$rgb = ImageColorAt($img, $w, $h);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
if($w == $width){
echo '[br /]';
}else{
echo '<span style="color:rgb('.$r.','.$g.','.$b.');">#</span>';
}
}
}
}
?>
</body>
</html>



CAPTCHA de imagen avanzada
Esta es su CAPTCHA básicos que usted puede encontrar en muchos sitios web para ayudar a detener a los robots.
image.php


<?php
// Font directory + font name
$font = 'fonts/Disney.ttf';
// Total number of lines
$lineCount = 40;
// Size of the font
$fontSize = 40;
// Height of the image
$height = 50;
// Width of the image
$width = 150;
$img_handle = imagecreate ($width, $height) or die ("Cannot Create image";
// Set the Background Color RGB
$backColor = imagecolorallocate($img_handle, 255, 255, 255);
// Set the Line Color RGB
$lineColor = imagecolorallocate($img_handle, 175, 238, 238);
// Set the Text Color RGB
$txtColor = imagecolorallocate($img_handle, 135, 206, 235);

// Do not edit below this point
$string = "abcdefghijklmnopqrstuvwxyz0123456789";
for($i=0;$i<6;$i++){
$pos = rand(0,36);
$str .= $string{$pos};
}
$textbox = imagettfbbox($fontSize, 0, $font, $str) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($img_handle, $fontSize, 0, $x, $y, $txtColor, $font , $str) or die('Error in imagettftext function');
for($i=0;$i<$lineCount;$i++){
$x1 = rand(0,$width);$x2 = rand(0,$width);
$y1 = rand(0,$width);$y2 = rand(0,$width);
imageline($img_handle,$x1,$y1,$x2,$y2,$lineColor);
}
header('Content-Type: image/jpeg');
imagejpeg($img_handle,NULL,100);
imagedestroy($img_handle);

session_start();
$_SESSION['img_number'] = $str;
?>
form.php

<form action="result.php" method="post">
<img alt="Random Number" src="image.php">
<input type="text" name="num">[br /]
<input type="submit" name="submit" value="Check">
</form>
result.php

<?php
session_start();
if($_SESSION['img_number'] = $_POST['num']){
echo'The number you entered doesn\'t match the image.[br /]
<a href="form.php">Try Again[/url][br /]';
}else{
echo'The numbers Match[br /]
<a href="form.php">Try Again[/url][br /]';
}
?>



Inicio de sesión de usuario simple

Este pequeño tutorial muestra los nuevos usuarios cómo hacer un simple usuario de acceso con un formulario de acceso y consulta de base de datos.
login_page.php


<form action="verify.php" method="post">
User Name:[br /]
<input type="text" name="username">[br /][br /]
Password:[br /]
<input type="password" name="password">[br /][br /]
<input type="submit" name="submit" value="Login">
</form>
verify.php

<?php
if(isset($_POST['submit'])){
$dbHost = "localhost"; //Location Of Database usually its localhost
$dbUser = "xxxx"; //Database User Name
$dbPass = "xxxxxx"; //Database Password
$dbDatabase = "db_name"; //Database Name
$email = '[email protected]';

$db = mysql_connect($dbHost,$dbUser,$dbPass)or die("Error connecting to database.";
//Connect to the databasse
mysql_select_db($dbDatabase, $db)or die("Couldn't select the database.";
//Selects the database

/*
The Above code can be in a different file, then you can place include'filename.php'; instead.
*/

//Lets search the databse for the user name and password
//Choose some sort of password encryption, I choose MySQL's built in
//Password function (Not In all versions of MySQL).
$query = sprintf("SELECT * FROM users_table
WHERE username='%s' AND
password=PASSWORD('%s') LIMIT 1",mysql_real_escape_string($_POST['username']),mysql_real_escape_string($_POST['password']));
//Search for a row
$sql = mysql_query($query);
if($sql){
$row = mysql_fetch_array($sql);
if($row){ //If there is a row start a session with values, then transfer to the users page
session_start();
$_SESSION['username'] = $row['username'];
$_SESSION['fname'] = $row['first_name'];
$_SESSION['lname'] = $row['last_name'];
$_SESSION['logged'] = TRUE;
header("Location: users_page.php";
}else{ //If there isn't a row return the user to a login page
header("Location: login_page.php";
exit;
}
}else{
// There was some sort of error, check your email
mail($email, 'MySQL Error', mysql_error());
header("Location: login_page.php";
exit;
}
}else{ //If the form button wasn't submitted go to the index page, or login page
header("Location: index.php";
exit;
}
?>
users_page.php

<?php
session_start();
if($_SESSION['logged']){
header("Location: login_page.php";
exit;
}
echo 'Welcome, '.$_SESSION['username'];
?>

Datos archivados del Taringa! original
0puntos
2,349visitas
0comentarios
Actividad nueva en Posteamelo
0puntos
4visitas
0comentarios
Dar puntos:

Dejá tu comentario

0/2000

Autor del Post

p
pinocar🇦🇷
Usuario
Puntos0
Posts26
Ver perfil →
PosteameloArchivo Histórico de Taringa! (2004-2017). Preservando la inteligencia colectiva de la internet hispanohablante.

CONTACTO

18 de Septiembre 455, Casilla 52

Chillán, Región de Ñuble, Chile

Solo correo postal

© 2026 Posteamelo.com. No afiliado con Taringa! ni sus sucesores.

Contenido preservado con fines históricos y culturales.