-1
  $fullurl=$_SERVER['PATH_INFO'];
  if(isset($_POST['name']) && isset($_POST['login']) && isset($_POST['pass']))
  {   

            echo '
              <form action=".'$fullurl'." method="POST"/>
              <table width="1000" border="1" cellpadding="10" id="navigationBar">
                  <tr>
                    <td> <a href="/PoliticalForum/controlPanel.php">Control Panel</a></td>
                    <td> <a href="/PoliticalForum/checkEmail.php">Donate</a> </td>
                    <td> <a href="/PoliticalForum/mainHome.php">Logout</a> </td>
                  </tr>
               </table>
            ';
  }
  else
  { 

        echo '
          <form action=".'$fullurl'." method="POST"/>
          <table width="1000" border="1" cellpadding="10" id="navigationBar">
              <tr>
                <td> <a href="/PoliticalForum/Registration.php">Register</a></td>
                <td> <a href="/PoliticalForum/controlPanel.php">Control Panel</a></td>
                <td> <a href="/PoliticalForum/checkEmail.php">Donate</a> </td>
                <td align="right">name:<input name="name" type="text" /></td>
                <td>password:<input name="pass" type="text" /> <input name="login" type="submit" value="Login" /> </td>
              </tr>
           </table>
           ';
  }

I want the same url to be passed to action, but it gives me a mistake:

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\xampp\htdocs\PoliticalForum\headerSite.php on line 9

and also will the $fullurl will give me the current page url?

knittl
  • 246,190
  • 53
  • 318
  • 364
Dmitry Makovetskiyd
  • 6,942
  • 32
  • 100
  • 160
  • Maybe use [heredoc string syntax](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc) to avoid such mistakes. – mario Oct 18 '11 at 17:10

5 Answers5

2

Replace

<form action=".'$fullurl'." method="POST"/>

with

<form action="' . $fullurl .'" method="POST"/>
stealthyninja
  • 10,343
  • 11
  • 51
  • 59
1

You have swapped the concatenation operator and single quotes:

echo '<form action="'.$fullurl.'" … ';
knittl
  • 246,190
  • 53
  • 318
  • 364
0

You have single quotes around your variable $fullurl when you're outputting the form...just remove those and you should be fine

echo '
  <form action="' . $fullurl . '" method="POST"/>
  etc...
Clive
  • 36,918
  • 8
  • 87
  • 113
  • This is what i have got and this is what i get : Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\xampp\htdocs\PoliticalForum\headerSite.php on line 12 – Dmitry Makovetskiyd Oct 18 '11 at 17:12
  • You still haven't made the fix suggested above, look closely at where your full stops and single quotes are around `$fullurl`...at the moment they're the wrong way round – Clive Oct 18 '11 at 17:17
  • Yeah, I corrected that. Now it works. Look at the new mistake update above that I get, concerning $_SERVER[PATH_INFO] – Dmitry Makovetskiyd Oct 18 '11 at 17:23
  • If you want to post to the same page try `$fullurl = $_SERVER['REQUEST_URI']` instead. Otherwise try changing it to `$fullurl = '/' . $_SERVER['PATH_INFO']`. That will relate the URL to your document root and should work – Clive Oct 18 '11 at 17:28
  • 1
    Also see [this post](http://stackoverflow.com/questions/5629683/serverpath-info-and-serverporig-path-info-in-php) to understand why `$_SERVER['PATH_INFO']` would be empty – Clive Oct 18 '11 at 17:29
  • @Clive - good info, didn't know that about PATH_INFO. Thanks. – Nathan Loding Oct 18 '11 at 22:01
0

Change the two <form /> lines to this:

<form action="'.$fullurl.'" method="POST"/>

You have your single quotes in the wrong spot.

$_SERVER['PATH_INFO'] would contain everything after the domain, so if it's http://domain.com/something/else it would contain /something/else.

http://php.net/manual/en/reserved.variables.server.php

Nathan Loding
  • 3,185
  • 2
  • 37
  • 43
  • Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\xampp\htdocs\PoliticalForum\headerSite.php on line 12 ---i still get this – Dmitry Makovetskiyd Oct 18 '11 at 17:10
  • Why does it tell me this: Notice: Undefined index: PATH_INFO in C:\xampp\htdocs\PoliticalForum\headerSite.php on line 5 on this: $fullurl=$_SERVER['PATH_INFO']; – Dmitry Makovetskiyd Oct 18 '11 at 17:16
0
<?php
 $fullurl=$_SERVER['PATH_INFO'];
 if(isset($_POST['name']) && isset($_POST['login']) && isset($_POST['pass']))
 {   

        echo '
          <form action="' . $fullurl . '" method="POST"/>
          <table width="1000" border="1" cellpadding="10" id="navigationBar">
              <tr>
                <td> <a href="/PoliticalForum/controlPanel.php">Control Panel</a></td>
                <td> <a href="/PoliticalForum/checkEmail.php">Donate</a> </td>
                <td> <a href="/PoliticalForum/mainHome.php">Logout</a> </td>
              </tr>
           </table>
        ';
}
else
{ 

    echo '
      <form action="' . $fullurl . '" method="POST"/>
      <table width="1000" border="1" cellpadding="10" id="navigationBar">
          <tr>
            <td> <a href="/PoliticalForum/Registration.php">Register</a></td>
            <td> <a href="/PoliticalForum/controlPanel.php">Control Panel</a></td>
            <td> <a href="/PoliticalForum/checkEmail.php">Donate</a> </td>
            <td align="right">name:<input name="name" type="text" /></td>
            <td>password:<input name="pass" type="text" /> <input name="login" type="submit" value="Login" /> </td>
          </tr>
       </table>
       ';
}
aphill70
  • 38
  • 4