Jump to content

Using HTML and PHP in the same echo""; tags


Epicballzy

Recommended Posts

I'm trying to learn php, and I've picked up a php/mysql member system type script, and I'm trying to put the login/sign-up forms into my own pages. The problem I'm having though is getting PHP and HTML to work in the same echo"";
 
This is the like I'm getting the errors at.
<form name="login" action='".$_SERVER['PHP_SELF']."' method="post" class="box login">

I've tried switching around the tags, from " to ' but that didn't work.

 

Any suggestions?

 

This is probably more of what you're going after

echo '<form name="login" action="'.$_SERVER['SCRIPT_NAME'].'" method="post" class="box login">';

Technically html attributes are supposed to have double quotes.  The way you had it the action would have had single quotes.  But if all you're doing is submitting the form to the same page it resides on, then just leave the action blank.  Also do not use the $_SERVER['PHP_SELF'] cause it is a big security risk, the SCRIPT_NAME or blank like I already suggested.

This is probably more of what you're going after

echo '<form name="login" action="'.$_SERVER['SCRIPT_NAME'].'" method="post" class="box login">';

Technically html attributes are supposed to have double quotes.  The way you had it the action would have had single quotes.  But if all you're doing is submitting the form to the same page it resides on, then just leave the action blank.  Also do not use the $_SERVER['PHP_SELF'] cause it is a big security risk, the SCRIPT_NAME or blank like I already suggested.

 

I removed the $_SERVER['SCRIPT_NAME'] and it worked. Thanks you!

Archived

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

×
×
  • 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.