Jump to content

PHP_SELF in echo


Ptsface12

Recommended Posts

Hello,

I am trying to use PHP_SELF in this form, however I get the error at the botom of the page.  Any help is brilliant!

 

<head>
<link type="text/css" rel="stylesheet" href="http://habbtalk.com/Version2/_content/style.css" />
<style>
.divider {
border-bottom: 1px solid #ADADAD;
font-family: "Tahoma", Arial, Verdana;
margin-bottom: 5px;
color: #ADADAD;
font-weight: bold;
font-size: 13px;
width: 440px;
}
form {

			padding: 0;
			margin: 0;

		}

		.wrapper {

			background-color: #fcfcfc;
			width: 300px;
			margin: auto;
			padding: 5px;
			margin-top: 15px;

		}

		.good, .bad {

			padding: 5px;	
			margin-bottom: 5px;

		}

		.good strong, .bad strong {

			font-size: 12px;
			font-weight: bold;

		}

		.good {

			background-color: #d9ffcf;
			border-color: #ade5a3;
			color: #1b801b;

		}

		.bad {


			background-color: #ffcfcf;
			border-color: #e5a3a3;
			color: #801b1b;

		}

		input, select, textarea {

			border: 1px #e0e0e0 solid;
			border-bottom-width: 2px;
			padding: 3px;

		}

		input {

			width: 170px;

		}

		input.button {

			width: auto;
			cursor: pointer;
			background: #eee;

		}

		select {

			width: 176px;

		}

		textarea {

			width: 288px;

		}

		label {

			display: block;
			padding: 3px;

		}
</style>
</head>

<div class="content_container">
            	<div class="center_pink_header">
                	<img src="scripts/header.php?size=7&width=1&text=ADD YOURSELF TO THE SPOTLIGHT!&colour=pink" alt="Add Yourself!" />
                </div>
                <div class="center_box">
<br/>
<div class="textContainer"><?php 
    include("../_spotlight/config.php"); 
    if ($_POST[spotlight]) { 
    $username = $_POST[username]; 
    $hotel = $_POST[hotel]; 

    if($username==NULL) { 

    echo "Whoops! You left something blank. Please go back and rectify this problem."; 
    }else{ 

    $checkuser = mysql_query("SELECT username FROM users WHERE username='$username'"); 
    $checkuser2 = mysql_num_rows($checkuser); 

    if ($checkuser2>0) { 

    echo "Uh-Oh! A user with this name has already been added."; 
    }else{ 

    $username = htmlspecialchars($username); 
    $hotel = htmlspecialchars($hotel); 
    $query = mysql_query("INSERT INTO users (username, hotel) VALUES('$username','$hotel')"); 

    							echo "<div class=\"good\">";
						echo "<strong>Success</strong>";
    							echo "</div>";

    }}} 

    else { 
    echo ("<form method=\"POST\" action=\"$_SERVER['PHP_SELF']\" ><center> 
    <b>user Name:</br> <input type=\"text\" class=\"input\" size=\"25\" maxlength=\"50\" name=\"username\"><br /> 
    <b>Hotel:</br> 
    <select size=\"1\" name=\"hotel\" class=\"select\"> 
    <option value=\".com\">user International</option> 
    <option value=\".ca\">user CA</option> 
    <option value=\".com.au\">user AU</option> 
    </select> 
    <br /> <br>
    <input name=\"spotlight\" type=\"submit\" class=\"button\" value=\"Add Me to the Spotlight!\"> 
    </center> </form>"); 
    } 
?>
<br/>
<br/>
                </div>
            </div>     <div class="center_box_bottom"></div> 

 

The error I get is:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/habbofea/public_html/v1/_content/add.php on line 140

 

Any help appreciated!

 

Best Wishes,

Ptsface12

Link to comment
Share on other sites

Hello,

Sorry; It's the form where it echo's out:

 echo ("<form method=\"POST\" action=\"$_SERVER['PHP_SELF'];\"><center> 

 

Best Wishes,

Ptsface12

 

Don't use $_SERVER ['PHP_SELF']... http://markjaquith.wordpress.com/2009/09/21/php-server-vars-not-safe-in-forms-or-links/

 

But to answer your question...  Firstly you have three closing brakects two lines above 140 }}}...

 

Secondly

 

echo ("<form method=\"POST\" action=\"$_SERVER['PHP_SELF'];\"><center> 

 

You added a semicolon at the end of $_SERVER['PHP_SELF']...

Link to comment
Share on other sites

Is this because there's to many of something?

 

Or not enough of it's matching tag.. You probably needed that 3rd } that was referred to above. Try adding it back in and see if that helps

Link to comment
Share on other sites

Nope, I still get errors unfortunately.

 

K. Worth a shot.

 

I just looked at your op, and line 140, when your echoing the $_SERVER['PHP_SELF'], since you're echoing it in double quotes, you don't need the single quotes inside the brackets so try

echo "$_SERVER[php_SELF]"

 

Posting the most recent code might help too

Link to comment
Share on other sites

To really answer your question, it is because you were including an associative array inside of the echo. The single quotes mess it up, in cases such as that use braces {} to include the variable.

 

echo ("<form method=\"POST\" action=\"{$_SERVER['PHP_SELF']}\"><center>"); 

 

WOuld have solved it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.