Jump to content


Photo

Embedding PHP


  • Please log in to reply
5 replies to this topic

#1 Mirek

Mirek
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 September 2006 - 12:03 AM

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

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



thx in advance.



#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 04 September 2006 - 12:06 AM

PHP_SELF is the same page

I dont understand what you are asking?
Tell me the problem, I will try tell you the solution

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 September 2006 - 12:10 AM

Use this:
$a_status = '<form action="' . $_SERVER['PHP_SELF']; . '" method="post" name="form1" id="form1"> ';


#4 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 04 September 2006 - 12:16 AM

to include another page, u would use
<?php
include("file.php");
?>
or
require
include_once
require_once
Tell me the problem, I will try tell you the solution

#5 Mirek

Mirek
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 September 2006 - 12:23 AM

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

#6 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 04 September 2006 - 01:31 AM

PHP_SELF has vulnerabilities.. use SCRIPT_NAME instead, and to be fully compat, use full URI not just relative:
<?php

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

?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users