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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Edited by Epicballzy
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.