Jump to content

Archived

This topic is now archived and is closed to further replies.

Mirek

Embedding PHP

Recommended Posts

Hi there,

I am trying to create a form which gets added to a page via an include file but can not work out how to insert ' php $_SERVER['PHP_SELF']; ' in it so when it gets loaded from the variable it actually works.

I have tried many different ways and its got me kind of beat as it either comes back with just useless text or a php error.


current code
[code]

$a_status = '<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="form1" id="form1"> ' ;

[/code]


thx in advance.

Share this post


Link to post
Share on other sites
Use this:
[code=php:0]$a_status = '<form action="' . $_SERVER['PHP_SELF']; . '" method="post" name="form1" id="form1"> ';[/code]

Share this post


Link to post
Share on other sites
to include another page, u would use
<?php
include("file.php");
?>
or
require
include_once
require_once

Share this post


Link to post
Share on other sites
Ahh excelent Wildteen, thx

That did the trick except for the ';' .

I am sure I would have tried that but yeah thats coding.

----------------------------------

onlyican -

the query refers to including a valid link in a form stored in a varaible that does not cause an error when echoed as that variable from an include file.

Cheers

Share this post


Link to post
Share on other sites
PHP_SELF has vulnerabilities.. use SCRIPT_NAME instead, and to be fully compat, use full URI not just relative:
[code]<?php

echo '<form action="http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '" method="post">';

?>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.