سلام
یه فرم تماس با ما php ساختم که می خوام این صفحه php رو بذارم توی یه صفحه html
چطور باید این کارو انجام بدم؟
بهترین راه چیه؟
سلام
یه فرم تماس با ما php ساختم که می خوام این صفحه php رو بذارم توی یه صفحه html
چطور باید این کارو انجام بدم؟
بهترین راه چیه؟
کاری نداره عزیزم.خیلی سادست.من یه فایل برات پیوست همین پستم کردم که یه فایل ساده اچ تی ام ال هست کد پیشفرضشم توش گذاشتم اسم صفحه رو نوشتم Page Name بجاش اسم دلخواهتو بنویس و بین خط 11 و 13 نوشتم (mahale Cod PHP) اونجا به جای این عبارت کدهای پی اچ پیتو بزار
یعنی میخواید مثلا پسوند این صفحه html باشه و پی اچ پی parse اش نکنه؟
اگه اینه به نظر من ۲ تا راه هست:
۱. از iframe استفاده کنید
۲. با AXAJ محتوایی رو که php تولید می کنه لود کنید توی html .
امیدوارم کمکی کرده باشم.
کد php رو بصورت جاوااسکریپت بنویسید و اون رو داخل html فراخوانی کنید
اول توی html اصلی یک div درست کنید مثلا با آی دی changable-div
کد:<!-- some html here --> <div id='changable-div' > <!-- leave empty for now --> </div>
سپس توی جاوا اسکریپت فانکشن بسازین:
که تولید کننده درخواست آژاکس در همهی مرورگر ها هست. سپس یک فانکشن دیگه بسازین و وصل اش کنین به یه دکمهای، چیزی:کد://Gets the browser specific XmlHttpRequest Object function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); //Not IE } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); //IE } else { //Display your error message here. //and inform the user they might want to upgrade //their browser. alert("Your browser doesn't support the XmlHttpRequest object. Better upgrade to Firefox."); } }
و تموم!کد://Get our browser specific XmlHttpRequest object. var receiveReq = getXmlHttpRequestObject();Next we will write our function that is called when a user clicks our hyperlink. This function will initiate the asycronous call. //Initiate the asyncronous request. function sayHello() { //If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call. if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { //Setup the connection as a GET call to SayHello.html. //True explicity sets the request to asyncronous (default). receiveReq.open("GET", 'YOUR_PHP_SCRIPT_HERE.php', true); //Set the function that will be called when the XmlHttpRequest objects state changes. receiveReq.onreadystatechange = handleSayHello; //Make the actual request. receiveReq.send(null); } }
در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)