Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> wyświetlanie echo pomiędzy stronami
pepa543543
post 18.04.2017, 13:02:48
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 18.04.2017

Ostrzeżenie: (0%)
-----


Cześć, dopiero się uczę i mam problem z wyświetleniem $msg. Chce by $msg było wyświetlane w index.php po kliknięciu w submit i sprawdzeniu (w osobnym pliku register.php) czy jest email poprawny lub nie

posiadam plik index.php

  1. <?php
  2. include 'core/int.php'; // zawiera $msg = ' '; oraz $db
  3. include 'includes/overall/header.php'; // header, content
  4. echo $msg;
  5. ?>
  6.  
  7. <?php include 'includes/overall/footer.php'; ?> // footer



plik register.php

  1. <?php
  2.  
  3. include 'core/int.php'; // $db, $msg
  4.  
  5. if(!empty($_POST['email']) && isset($_POST['email']) && !empty($_POST['email_r']) && isset($_POST['email_r'])) {
  6.  
  7. $email=($_POST['email']);
  8. $email_r=($_POST['email_r']);
  9.  
  10. $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/';
  11.  
  12. if(preg_match($regex, $email)) {
  13.  
  14. $msg = 'poprawny email'; }
  15.  
  16. else {
  17.  
  18. $msg = 'niepoprawny email';
  19.  
  20. }
  21.  
  22. ?>
  23.  

Go to the top of the page
+Quote Post
viking
post 18.04.2017, 13:23:57
Post #2





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


A gdzie includujesz to register? Sprawdzanie maila jest niepoprawne - użyj funkcji http://php.net/manual/en/function.filter-var.php


--------------------
Go to the top of the page
+Quote Post
pepa543543
post 18.04.2017, 13:54:05
Post #3





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 18.04.2017

Ostrzeżenie: (0%)
-----


incaluda register mam w int.php zmieniłem do index.php to też nie działa

Ten post edytował pepa543543 18.04.2017, 14:00:53
Go to the top of the page
+Quote Post
viking
post 18.04.2017, 14:00:49
Post #4





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Jeśli jest to ciągiem pisane bez żadnych funkcji to zmienne powinny działać. Możesz spróbować include_once.


--------------------
Go to the top of the page
+Quote Post
Pyton_000
post 18.04.2017, 14:08:06
Post #5





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


zmieniałeś na require zamiast include?
Go to the top of the page
+Quote Post
pepa543543
post 18.04.2017, 14:25:35
Post #6





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 18.04.2017

Ostrzeżenie: (0%)
-----


nie nie próbowałem, link do kodu który mam: kod
Go to the top of the page
+Quote Post
viking
post 18.04.2017, 14:40:48
Post #7





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Na początek zmień adres tego formularza z register.php na ?register


--------------------
Go to the top of the page
+Quote Post
Tomplus
post 18.04.2017, 14:43:49
Post #8





Grupa: Zarejestrowani
Postów: 1 836
Pomógł: 226
Dołączył: 20.03.2005
Skąd: Będzin

Ostrzeżenie: (0%)
-----


Chcesz wyświetlić $msg z pliku index.php?

To dlaczego masz w register.php $msg = ''; w linii 5?
Tym sposobem z góry nadpisujesz sobie wiadomości przypisane do zmiennej wcześniej.

Jak chcesz dopisać jakieś informacje to stosuj kropkę przed znakiem =
  1. $msg .= 'Kolejna wiadomosc';

Go to the top of the page
+Quote Post
pepa543543
post 18.04.2017, 15:06:11
Post #9





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 18.04.2017

Ostrzeżenie: (0%)
-----


Tomplus ten $msg chce wyświetlić z register.php do index.php
Go to the top of the page
+Quote Post
viking
post 18.04.2017, 15:21:51
Post #10





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Powiedziałem już co masz zrobić. Formularz ma przenosić do index.php?register a nie register.php.


--------------------
Go to the top of the page
+Quote Post
pepa543543
post 18.04.2017, 15:26:30
Post #11





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 18.04.2017

Ostrzeżenie: (0%)
-----


zmieniłem i nadal nie wyświetla mi tego echo w index
Go to the top of the page
+Quote Post
viking
post 18.04.2017, 15:38:53
Post #12





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Działa tylko nie masz żadnego warunku jeśli pola są puste.


--------------------
Go to the top of the page
+Quote Post
pepa543543
post 18.04.2017, 15:43:09
Post #13





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 18.04.2017

Ostrzeżenie: (0%)
-----


if(!empty($_POST['email']) && isset($_POST['email']) && !empty($_POST['email_r']) && isset($_POST['email_r']))
Go to the top of the page
+Quote Post
viking
post 18.04.2017, 16:23:23
Post #14





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Tutaj masz umieszczone warunki jeśli dane są wprowadzone. Daj echo po tym ifie i zobacz czy działa. Jakie kroki podejmujesz żeby powiedzieć że nie wyświetla się?


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 26.04.2024 - 14:09