Jump to content

[SOLVED] Calling website functions into a HTML Document


Tylor Eddy

Recommended Posts

G'day Guys,

I am creating a popout login page, this page requires the form in a HTML document which is fine, but is there a way of calling a particular file to integrate the HTML document with my site, currently none of the php for the login form is working as its not a tpl file and im presuming the sites functions require a particular file to be called within the HTML document for any of the php to become effective.

Anyone know how i can go about getting this to work ?

Regards

Tylor

Link to comment
Share on other sites

G'day Guys,

I've been looking into the documentation and in order to get the website functions to work i need to call codon.config.php into the document. Basically i want to call the login form from a .html document instead of a .tpl so it will be compatible with my popout login box.

Currently i have this but i am not doing something right, so a nudge in the right direction would be handy right now :)

<head>
<script>
include '/core/codon.config.php';

// You can then access the API normally from here
</script>
</head>
<form name="loginform" action="<?php echo url('/login'); ?>" method="post">
   Sign-in with your pilot id or email, or <a href="<?php echo url('/registration'); ?>">register</a><br />
  <input type="text" name="email" value="" onclick="this.value=''" />
  <input type="password" name="password" value="" />
  <input type="hidden" name="remember" value="on" />
  <input type="hidden" name="redir" value="index.php/profile" />
  <input type="hidden" name="action" value="login" />
  <input type="submit" name="submit" value="Log In" />
   </form>
<script type="text/javascript">
 $("#loginform").submit(function(ev) {
   if ($("#username").val() == "" | $("#password").val() == "") {
  $.lightbox().shake();
  ev.preventDefault();
   }
 });
</script>

This is the error i recieve when trying to submit the form.

Forbidden
You don't have permission to access /< on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Link to comment
Share on other sites

include '/core/codon.config.php';

Needs to be wrapped in PHP tags for starters mate. First, not everyone has Javascript turned on, second it just wouldn't work.

So you need to call it like this:

<?php

include '/core/codon.config.php';

?>

I tried this in HTML and it didn't work, you must name the files .php

  • Like 1
Link to comment
Share on other sites

The form itself is still the stock phpvms login form which i placed into a html file. What i tried to do was use the HTML file which is used by the lightbox module to display the login form inside this module ( the module is this one here: http://codecanyon.ne...volution/115655). I can view the form fine, but the php functions wont work and now i know why. My delema now is working out how to modify that module to accept a .tpl or .php file to get the form to work correctly. i'm presuming theres no way to manipulate the login form to not require the need for php ?

Also would something like this work ?

http://www.zubrag.com/forum/index.php?topic=61.0

Link to comment
Share on other sites

Ok i have found out that i can in fact use a .php file with this lightbox module, and i've tried calling the form with php but im not quite sure on the correct syntax for this. Here is what i have

<head>
<script>
<?php
include '/core/codon.config.php';
?>
// You can then access the API normally from here
</script>
</head>
<body>
<?php
{
				 echo '<form name="loginform" action="<?php echo url('/login'); ?>" method="post">';
				 echo 'Sign-in with your pilot id or email, or <a href="<?php echo url('/registration'); ?>">register</a><br />';
echo '<input type="text" name="email" value="" onclick="this.value=''" />';
echo '<input type="password" name="password" value="" />';
echo '<input type="hidden" name="remember" value="on" />';
echo '<input type="hidden" name="redir" value="index.php/profile" />';
echo '<input type="hidden" name="action" value="login" />';
echo '<input type="submit" name="submit" value="Log In" />';
				 echo '</form>';
}
?>
</body>

how can i display my form with php? any help would be great, im useless with php haha, but i'll learn it one day

This is the error it throws

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/qantasvi/public_html/newsite/lib/skins/qantasvi/pilot-login.php on line 14

Untitled-1_zps9b3b3c6e.jpg

Tylor

Link to comment
Share on other sites

Tylor, first the best advice I can give it to google the error PHP gives you. The PHP manual is very well-written and you can 9 times out of 10 find your own solution by doing so. It also helps you learn the basic of PHP by debugging code.

Anyway, I have commented what I did to clean you up, take a look at the differences and it'll help you understand. This isn't 100% sure to run with your script, but it is clean code as far as I can tell.


<head>
<?php
//No need for script tags around PHP. 
include '/core/codon.config.php';
?>
</head>

<body>
<?php
{
// You needed to escape a bunch of single quotes and remove the PHP calls within the PHP. You were echo'ing within an echo statement.
echo '<form name="loginform" action="/login" method="post">';
echo 'Sign-in with your pilot id or email, or <a href="/registration">register</a><br />';
// You need to use the backslash to "escape" the single quotes in the onclick function. 
echo '<input type="text" name="email" value="" onclick="this.value=\'\'" />';
echo '<input type="password" name="password" value="" />';
echo '<input type="hidden" name="remember" value="on" />';
echo '<input type="hidden" name="redir" value="index.php/profile" />';
echo '<input type="hidden" name="action" value="login" />';
echo '<input type="submit" name="submit" value="Log In" />';
echo '</form>';
}
?>
</body>

  • Like 1
Link to comment
Share on other sites

Thanks for your support Paul, and the including the corrections for the mistakes i made, very handy.

now i'm recieving a codon.config related error. This is what im getting

Warning: include(/core/codon.config.php) [function.include]: failed to open stream: No such file or directory in /home/qantasvi/public_html/newsite/lib/skins/qantasvi/pilot-login.php on line 4
Warning: include() [function.include]: Failed opening '/core/codon.config.php' for inclusion (include_path='.:/usr/lib/php') in /home/qantasvi/public_html/newsite/lib/skins/qantasvi/pilot-login.php on line 4

I've tried adding a full directory but that isn't co-operating.

Other than that the form is displaying, so we're almost there! :D

Link to comment
Share on other sites

OK, so when you read that error, you can see it is telling you something is missing and the offending referral link is on line 4 and it's called 'core/codon.config.php'. So what that's saying, is that the path to codon.config.php is incorrect.

Within phpvms, you can create a link back to the top directory of your site using SITE_URL. This is defined within the local.config.php file, but typically it would direct you to the root folder of your installation. So when you have links that point to something way outside your skin folder, use that to create links that will work. In this case, it won't work because you're using a PHP file, not a template within the MVC structure.

So a better solution overall is to create a custom module and call it through a template. But that's beyond what I'm explaining. This will get you up and running, change line 4 to read:

include $_SERVER['DOCUMENT_ROOT'].'newsite/core/codon.config.php';

But when you move this to the root URL of the website, you'll need to remember to take away "newsite". Having said that, there is a way that s

  • Like 1
Link to comment
Share on other sites

G'day Paul,

Thanks for the help setting up the URL directory for the codon.config file, i now have no errors displaying on the lightbox module itself and the form is displaying normally. My issue now is when i went to test the form in an attempt to login, i am presented with this error.

Not Found
The requested URL /login was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Any Idea's on this one ?

Tylor

Link to comment
Share on other sites

Tylor, same as before, a link isn't correct. In this case, it's the form handler. It's looking for index.php/login.

echo '<form name="loginform" action="/login" method="post">';

I don't have time to help much today, sorry. So you'll need to figure out how to get it linked to the base_url/index.php/login.

  • Like 1
Link to comment
Share on other sites

G'day Paul,

Thats working fine, when attempting to login itself it throws the 404 error, like below

Not Found
The requested URL /login was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Thats not related to the codon.config file is it ? This was using the code you provided above to call on the codon.config file.

If you'd like i'll PM you the link to my site in development and you can take a look at it if it helps.

I was just thinking a little further about this issue, could it involved login.php within the core/modules/login folder ? or does codon.config.php overide the need for this ?

Regards

Tylor

Link to comment
Share on other sites

No it should be just the way the URI's are formed. Because you're changing the location it is normally called from, the default paths require changing. So you just need to add the /index.php to the front of them. On your website, it seems you have deleted or renamed the registration module, so it doesn't work, but the below code works fine in my test environment with a default phpvms.

<head>
<?php
include '/core/codon.config.php';
?>
</head>

<body>
<?php
{
echo '<form name="loginform" action="/index.php/login" method="post">';
echo 'Sign-in with your pilot id or email, or <a href="/index.php/registration">register</a><br />';
echo '<input type="text" name="email" value="" onclick="this.value=\'\'" />';
echo '<input type="password" name="password" value="" />';
echo '<input type="hidden" name="remember" value="on" />';
echo '<input type="hidden" name="redir" value="/index.php/profile" />';
echo '<input type="hidden" name="action" value="login" />';
echo '<input type="submit" name="submit" value="Log In" />';
echo '</form>';
}
?>
</body>

  • Like 1
Link to comment
Share on other sites

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.

Loading...
×
×
  • Create New...