سلام
من تصویر امنیتی رو در php ایجاد کردم می خوام در html استفاده کنم.وقتی من کد php رو داخل فایل html کپی می کنم. اصلا تصویر امنیتی رو نشون نمی ده یعنی کدهای php رو نشون نمی ده.آیا اسفاده از کد php داخل فایل htmlقاعده ی خاصی داره ؟
ممنون
Printable View
سلام
من تصویر امنیتی رو در php ایجاد کردم می خوام در html استفاده کنم.وقتی من کد php رو داخل فایل html کپی می کنم. اصلا تصویر امنیتی رو نشون نمی ده یعنی کدهای php رو نشون نمی ده.آیا اسفاده از کد php داخل فایل htmlقاعده ی خاصی داره ؟
ممنون
کد PHP توی فایل با پسوند HTML کار نمیکنه. باید پسوند فایل حتماً php. باشه.
سلام
این کد مربوط به تصویر امنیتیه.من نمی تونم این تصویر رو با عناصر اچ تی ام ال نشون بدم لطفا کمکم کنید
<?php
session_start();
//ايجاد يك تصوير جديد//
$img = imagecreatefrompng('a.png');
//اين تابع براي ايجاد اعداد تصادفي در تصوير است//
$numero = rand(1000, 9999);
//متغيير اعداد تصادفي داخل سيژن ذخيره مي شود.//
$_SESSION["captcha"] = $numero;
//به اعداد// RGB اختصاص دادن رنگ
$white = imagecolorallocate($img, 25, 0, 0);
imagestring($img, 30, 30, 12, $numero, $white);
//mime aks
header ("Content-type: image/png");
//ايجاد عكس به فرمت// png
imagepng($img);
?>
این هم فرم ثبت نام هس من می خوام تصویر رو اینجا نمایش داده بشه.
<!doctype html>
<html dir="rtl">
<head>
<title>In the name of God</title>
<link rel="stylesheet" type="text/css" href="b_style/style/menu.css">
<link rel="stylesheet" type="text/css" href="b_style/style/component_common.css">
<link rel="stylesheet" type="text/css" href="b_style/style/Background.css">
<link rel="stylesheet" type="text/css" href="b_style/style/div_style.css">
<link rel="stylesheet" type="text/css" href="b_style/style/panel.css">
</head>
<body>
</div>
<div align="right" style="margin-top:50px;">
<form action="reg.php" method="post">
<fieldset style="width:250px;height:500px;font-size:14px;text-align:right;position:relative;float:right;margin-right:170px;" align="right">
<legend align="right">
ثبت نــام
</legend>
<div style="margin-top:15px;">نام<input style="position:absolute;right:90px;width:120px;" type="text" name="txtfnam"/></div>
<div style="margin-top:15px;">نام خانوادگي<input style="position:absolute;right:90px;width:120px;" type="text" name="txtlnam"/></div>
<div style="margin-top:15px;">نام کاربري<input style="position:absolute;right:90px;width:120px;" type="text" name="txtusername"/></div>
<div style="margin-top:15px;">پسورد<input style="position:absolute;right:90px;width:120px;" type="text" name="txtpass"/></div>
<div style="margin-top:15px;">تکرار پسورد<input style="position:absolute;right:90px;width:120px;" type="text" name="txtrepass"/></div>
<div style="margin-top:15px;">جنسيت<input style="position:absolute;right:90px;width:120px;" type="text" name="txtjens"/></div>
<div style="margin-top:15px;">آدرس الکترونيکي<input style="position:absolute;right:90px;width:120px;" type="text" name="txtmail"/></div>
<div style="margin-top:15px;">استان<input style="position:absolute;right:90px;width:120px;" type="text" name="txtostan"/></div>
<div style="margin-top:15px;">شهر<input style="position:absolute;right:90px;width:120px;" type="text" name="txtshahr"/></div>
<div style="margin-top:30px;text-align:center;"><input style="position:absolute;right:90px;width:70px;tex t-align:center;" value="ثبت نام" type="submit" name="sub1"/></div>
</fieldset>
</form>
</div>
</div>
</body>
</html>
بهترین راه حل شما آجاکس هست . شما باید تصویر را در PHP ایجاد کنید .
سپس در صفحه Html از کدهای جاوااسکریپت برای خواندن عکس و مقدار نمایشی در عکس استفاده کنید .
این کد رو توی صفحه ثبت نام یا همون html بگذارید :
<img src="php_img_file.php" />
نام فایل مورد نظر php رو تغییر بدید !
عکس نشون داده میشه
در ادامه سخنان دوستمون
siavashsay
فکر کنم منظور دوستمون این بود که پسوند فایلتون رو به php تغییر بدید این هم یک راهنمایی از طرف من
نیازی به تغییر پسوند به PHP نیست !
عکسی که با فایل PHP ساخته شده توی یک صفحه HTML هم نشون داده میشه با همون کدی که دادم ! اینو واسه این میگم واسه این که Action فرم ایشون به یک صفحه PHP هست ( reg.php ) البته اگه همون صفحه جاری نباشه !
توی اون صفحه reg.php هم مقدار سشن گرفته میشه و ثبت نام میشه !
ایشون فقط باید با همون کد عکس رو نشون بدن ! :)