Welcome Guest, Not a member yet? Register   Sign In
Can't get a view to load
#1

[eluser]OldRodKS[/eluser]
I am really new to CI, so I'm sure I am missing something really basic here... but I cannot get a view to load when I call a function directly from a URL.

I am working on a user registration system. The system sends an email to the user with an activation URL that looks like this:

Code:
http://localhost/ci_bannor/register/email_verification/6b84c572efd

Inside my register.php controller, I have a function called "email_verification" that is shown below:

Code:
public function email_verification() {
  $verifcode = $this->uri->segment(3);
  
  if ($verifcode == '') {  // no verification code - show error page
   $this->load->view("vVerifyError", $data);
  }

I put echo statements in here at various places to track down what's going on. $verifcode is getting the proper part of the URL like it should. When I have a code there, I can echo it out. When it's not there, it goes into the if block like it should, but it simply won't load the view. I don't get an error, it just doesn't load.

What am I doing wrong?
#2

[eluser]TWP Marketing[/eluser]
Code:
$this->load->view("vVerifyError", $data);

Do you have the var $data defined? I realize you are not posting all the function code, but that could cause a problem if not defined in your controller function
#3

[eluser]OldRodKS[/eluser]
Yes, $data was defined, but I've been removing stuff trying to get down to the root of the problem.

The line posted above should not have the ",$data" in it.

It still doesn't work though Smile
#4

[eluser]TWP Marketing[/eluser]
Code:
public function email_verification() {
  $verifcode = $this->uri->segment(3);
  
  if ($verifcode == '') {  // no verification code - show error page
   $this->load->view("vVerifyError", $data);
  }

The uri function segment() returns FALSE, so your if statement will miss it if the verify code is not in your URL. Try
Code:
...
if ($verifcode == FALSE){
...
#5

[eluser]OldRodKS[/eluser]
No change.

Here is how it looks now:

Code:
public function email_verification() {
  $verifcode = $this->uri->segment(3);
  
  if ($verifcode == FALSE) {
   echo "Verification code is blank";
   $this->load->view("vVerifyError");
  }

The echo statement displays whether it's =FALSE or ='', but with or without the echo statement, the view doesn't load.
#6

[eluser]TWP Marketing[/eluser]
Then the suspicion falls on the view code itself.
Could you change the view name to some other view which you know does work, as a test.
If it displays then please post the view code itself so we can debug from there.
#7

[eluser]OldRodKS[/eluser]
OK, changed it to display my page footer: $this->load->view('vPgFooter')

This is a view I use on every page and it works fine on all the other pages. It does not work when called in the code above.

Then I called the vVerifyError view from my main page and it displays fine, so the view itself is ok.

email_verification is part of my register controller. Could it have something to do with calling it via a URL?
#8

[eluser]TWP Marketing[/eluser]
I don't see how the URL would effect the use of the loader to move it to the browser.
You said there were not errors, I assume neither php error log nor the server error log have anything?
You get a blank screen? usually my server will glitch and report a problem on a blank screen.
#9

[eluser]TWP Marketing[/eluser]
another point, using a subview like your footer means that the rest of the html code is missing, hence a blank screen. Is the verify page a full html document, with html header data?
#10

[eluser]OldRodKS[/eluser]
No errors in php log or apache server log. Is there a codeigniter error log file someplace?




Theme © iAndrew 2016 - Forum software by © MyBB