Fukushousha Posted April 9, 2008 Share Posted April 9, 2008 Hello all!I made a login/register script following various tutorials and similar scripts flying around the net. I got one problem though.Whenever the sql query shows that we do have an authentication problem, be it username or password in every other script I saw they used the die() function to display an error message. What I wanted to do is display the login/register form again with a text message to show what the problem was. I tried to put php code in the function like that : die( " <h1>PRoblem</h1 <php loginForm(); ?>") but the php code did not execute. Anyone knows of any other way to do what I plan? I take it that it must be something really simple since it is what is done in every website around the net anyway , I am just new to php coding Link to comment Share on other sites More sharing options...
Ingolme Posted April 9, 2008 Share Posted April 9, 2008 die() will display a message and stop the PHP from running. If you just want to show a message and keep running the application then use echo().Oh, and you can't run PHP inside an outputte string.You would do something like this instead:echo "<h1>Problem</h1>";loginForm();And if loginForm() is supposed to return a string, then:echo "<h1>Problem</h1>" . loginForm(); Link to comment Share on other sites More sharing options...
Fukushousha Posted April 9, 2008 Author Share Posted April 9, 2008 Oh , I see. I just thought that die was the good way of handling such a situation. I also thought that you could run php from an output string variable, but I guess I was wrong Nonetheless the way you propose is a really nice and damn simple( why didn't I think of it? ). Thanks ingolme. Link to comment Share on other sites More sharing options...
Synook Posted April 10, 2008 Share Posted April 10, 2008 Well, your already in a PHP block, why need to create another one? You can still die() die("<h1>Problem</h1>" . loginForm()); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.