Getting menu value from MySQL

I added user register & login system into my website with PHP jQuery and MySQL. I want if the user logged in, at the main page menu change the login buttons value to the user’s name from MySQL.
I tried some sources from the internet but it didn’t work

by the way here’s the project : https://zafernci.xyz/uploadd/

1

My Menu:

    <a class="active" href="#">Home</a>
    <a href="#">Contact</a> 
    <a href="#">Products</a> 
    <a id="sign-up" href="#" onclick="SignUp()">Sign Up</a> 
       <?php if(isset($_SESSION["username"])): ?>
    <a href="logout.php">Logout  ///.$_SESSION["username"]. I tried this code but that too didn't work//// </a>
       <?php else: ?>
    <a id="log-in" href="#" onclick="LogIn()">Log In</a>
       <?php endif; ?> 
       </div>  

The Login System with MySQL:

if(isset($_POST["username"]) && isset($_POST["password"]))
{
 $username = mysqli_real_escape_string($connect, $_POST["username"]);
 $password = md5(mysqli_real_escape_string($connect, $_POST["password"]));
 $sql = "SELECT * FROM users WHERE username = '".$username."' AND Password = '".$password."'";
 $result = mysqli_query($connect, $sql);
 $num_row = mysqli_num_rows($result);
 if($num_row > 0)
 {
  $data = mysqli_fetch_array($result);
  $_SESSION["username"] = $data["username"];
  echo $data["username"];
 }
}

Dynamically generated PDFs not showing in certain browser

I use Ezpdf to generate invoices in pdf format. Last year everything was fine. Nothing has changed from the ezpdf code. Pdfs showed up on PC and Macs with no problem. This year, on certain browsers, a white page is shown instead of a pdf. To show how picky this is. On two macs (safari and Google) pdfs are generated perfectly. On another Mac the pdfs only show in Firefox. On certain Pcs they only show in Firefox but with misaligned margins at the top of page. I was wondering is anyone had come across something similar. Thank you.

Restrict live an input field comparing it to another field

I have a php page and these two inputs fields. My goal is to check if the second input is equal to first input (live) and make an error msg. The code i have so far is this:

<div class="input-group date" id="timepicker1"  
                                                                
    data-target-input="nearest">
    <input type="text" 

    class="form-control datetimepicker-input"
    data-target="#timepicker1"

    name="FirstDate" id="FirstDate"  />

</div>
<div class="input-group date" id="timepicker2"  
                                                                
    data-target-input="nearest">
    <input type="text" onclick="CheckForErrors()"

    class="form-control datetimepicker-input"
    data-target="#timepicker2"

    name="SecondDate" id="SecondDate"  />

</div>

In the end of the php i have a Javascript checking:

<script type="text/javascript">
    function CheckForErrors() {
      // Check if First Time is equal with second Time
      if (FirstDate == SecondDate) {
        alert("Error MSG!");
      }
      return false;
    }
</script>

Its not working, as u understand. Any help ?
PS. I’m a begginer so please be patient 😀

Why would wp_mail think it’s succeeding, but not actually send mail?

I am using the wp_mail function within WordPress, but it only works sometimes. When I look at the error log, it says that mail is succeeding. This function is also being used for another email being sent – but that one works (at least sometimes, anyway).

if ( wp_mail( $emailTo, $subject, $body, $headers ) ) {
    error_log('mail success');
} else {
    error_log('mail fail');
}

What am I missing?

Twilio Reject Call and Send to Voicemail

I have a simple call structure folder with PHP and XML on my server. To handle my incoming calls for my business.

I can’t seem to get it to forward to voicemail without errors.

Here is how the call gets triggered.

Customer Calls -> Routes to Webhook -> Handle-Incoming-Call.XML

    <?xml version="1.0" encoding="UTF-8"?>
<Response>
    
    <Redirect>handle-extension.php</Redirect>
</Response>

Then Handle-Extension.PHP looks like this

<?php
    header('Content-type: text/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>';

    echo '<Response>';

    
        # @start snippet
        echo '<Say>Thank you for calling, My Business</Say>';
        echo '<Dial record="true" timeout="15" action="voicemail.php">';
        echo '<Number url="screen-caller.xml">+10000000000</Number>';
        echo '</Dial>';
        # @end snippet
    
    echo '</Response>';
?>

Then Screen-Caller.XML looks like this (This is what me as a business will hear when I pick up)

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Gather action="handle-screen-input.php" numDigits="1">
        <Say>Call for Your Business</Say>
        <Say>To accept the call, press 1.</Say>
        <Say>To reject the call, press 2.</Say>
    </Gather>

</Response>

When I press 1 I get the call, but when I press 2 I want it to go to voicemial.

Here is the Handle-Screen-Input.PHP

<?php
    header('Content-type: text/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>';

    echo '<Response>';

    $user_pushed = (int) $_REQUEST['Digits'];

    if ($user_pushed == 1)
    {
        echo '<Say>Connecting, say hello.</Say>';
    }
    else {
        echo '<Hangup />';
    }

    echo '</Response>';
?>

I did a bypass for now so I created another Webhook to go to a TwimLets Forwarding Voicemail to Email when it fails.

Here is the fail message I get from LOGS

An attempt to retrieve content from https://website.com/callsystem/voicemail.php returned the HTTP status code 500. Falling back to http://twimlets.com/voicemail?Email=email%40email.com&Message=Please%20leave%20a%20message%20after%20the%20beep.&Transcribe=true&

So when it gets to the error it goes to my fallback WebHook, I still get the voicemail but I get tons of error logs at the end of the day.

I am trying to figure out what I am missing to get the voicemail.php to work.

Here is the voicemail.php code I found in one of the posts here in Stack.

header("content-type: text/xml");
    echo '<?xml version="1.0" encoding="UTF-8"?>';
    $email = $_REQUEST['email'];
?>
<Response>
    <?php if ($_REQUEST['DialCallStatus'] == 'completed') { ?>
            <Hangup/>
    <?php } else { ?>
            <Say>Sorry Our Business is not available at this time, Please leave a message at the tone.  Press the star key when finished.</Say>
            <Record transcribe="true" action="goodbye.php" transcribeCallback="voicemail-send.php?email=<?php echo $email; ?>" maxLength="120" finishOnKey="*" />
            <Say>I did not receive a recording.</Say>
            <Redirect>voicemail.php</Redirect>
    <?php } ?>
</Response>

Do I need to add a file name “voicemail-send.php” if so what is that structure look like?

Any help would be greatly appreciated. Thank you

What is the right way to add a new product property in WooCommerce?

I’ve just started learning about WordPress and WooCommerce. My problem is that products there lack properties like expiration date, origin or similar that I might think of in the future (for every single product these fields are probably going to be different, not that many duplicates). I know that it might be possible to achieve this functionality with attributes (?) but I’m not entirely sure. My idea is to create a module with a separate database which would have a relationship with each product (or post). Is that the right approach? What I am trying to achieve at the end of the day is to create a dashboard in the front end where some users will be able to add or edit certain products and those fields are necessary to be in that dashboard. Or maybe you have any other suggestions? Thank you.

PHP Get price from span

Im new in PHP. Can you tell me how can I get price from span named “wordCounterPrice”. I have something like this:

class getPrice {
    public $price;
    public function __construct($data){
        $this->price = addslashes($data['wordCounterPrice']);
    }
}
...
if(isset($_POST['count'])){
    echo '<script>location.href="#test"</script>';
    $price = new getPrice($_POST);
...
}

HTML:

<span id="wordCounterPrice" name="wordCounterPrice">0</span>
<button type="submit" name="count" id="count" class="btn btn-primary">Get it</button>

So much thanks

Create Tweet API not working for other users

I’ve created a Twitter developer account with my profile and passing cosumer_key, consumer_secret, token_id, and token_secret and If I’m hitting create-tweet 'https://api.twitter.com/1.1/statuses/update.json' API then I’m getting a proper response but if I’m creating tweets with other users credentials I’m getting an error
([errors]=> Array([code] => 32, [message] => Could not authenticate you.)). I’ve given read & write permission to my app as well.

    public function createTweet(Request $req) {
    Log::channel('twitterwebhook')->info($req->all());

    $access_token = $req->require('token_id');
    $acess_token_secret = $req->require('token_secret');
    $message = $req->require('message');
    $twitter = new TwitterAPI($access_token, $acess_token_secret);

    $response = $twitter->createTweet($message);
    
    if(isset($response->errors)){
        return error($response->errors, 4099);
    }
    $data = [
        'tweet_id'=> $response->id,
        'tweet_str_id' =>$response->id_str,
        'message' =>$response->text,
        'user_twitter_id'=>$response->user->id,
        'user_twitter_name'=>$response->user->name,
        'user_twitter_screen_name'=>$response->user->screen_name
    ];
    return success($data);
}

public function createTweet($tweet_message) {
    $postfields = [
        'status' => $tweet_message, 
        'trim_user' => false
    ];

    $twitterResponse =  $this->buildOauth($this->_update_url, 'POST')
                             ->setPostfields($postfields)
                             ->performRequest();
    return json_decode($twitterResponse);

}

@php tag in blade template can’t reach inline variable

I am looping through products which has all my configurable options available. Inside that i am looping through my items, when i get a match in product i want to display this product and item.

To do so i want to create a variable called $currentProduct.

@foreach($order['products'] as $product) // Configurable products
    @foreach($order['items'] as $item)  // Simple products
        @if ($item['product_type'] == 'simple')
            @if ($product['id'] === $item['product_id'])
                @php($currentProduct = $product) // error here $product undefined
                @php($currentItem = $item) // error here $item undefined
            @endif
        @elseif ($item['product_type'] == 'configurable')
            @if ($product['id'] == $item['parent_item']['product_id'])
                @php($currentProduct = $product) // error here $product undefined
                @php($currentItem = $item) // error here $item undefined
            @endif
        @endif
    @endforeach
@endforeach

I am new to laravel and blade templates and can’t seem to wrap my head around, why $product and $item is undefined when they are defined right above in same template.

Any help appreciated

how to display and hide the watermark on a video using ffmpeg

i’m new to ffmpeg i want to add any animation to the watermark
this is my php code:

$source=$_SERVER['DOCUMENT_ROOT']."/content/uploads/".$row['source'];
            $command = "ffmpeg -i ".$source." -i medada.png";
            $command .= " -filter_complex "[0:v][1:v]";
            $command .= " overlay=25:150""; 
            $str = rand();
            $result = hash("sha256", $str);
            $path_info = pathinfo($source);
            $extension=$path_info['extension'];
            $command .= " -c:a copy ".$_SERVER['DOCUMENT_ROOT']."/content/downloads/".$result.".".$extension."";

Unable to connect to localhost:2525

i’m trying to send email using google mail and i’m having this error i tried doing it with mailtrap it gaves me the same error
Connection could not be established with host localhost :stream_socket_client(): Unable to connect to localhost:2525 (No connection could be made because the target machine actively refused it)
i don’t know whats the relation between the localhost and the port 2525, i’m not trying to use the port this is my .env file

APP_ENV=local
APP_KEY=************************
APP_DEBUG=true
APP_URL=https:****************************

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=superett_super
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465  
[email protected]
MAIL_PASSWORD=GeForce7ThGen
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
MAIL_ENCRYPTION=tls

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

and this is my config/mail.php file i have already tried to change the host and the port in this file nothing works

<?php

return [
'default' => env('MAIL_MAILER', 'smtp'),

'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
            'port' => env('MAIL_PORT', 587),
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
            'auth_mode' => null,
        ],

        'ses' => [
            'transport' => 'ses',
        ],

        'mailgun' => [
            'transport' => 'mailgun',
        ],

        'postmark' => [
            'transport' => 'postmark',
        ],

        'sendmail' => [
            'transport' => 'sendmail',
            'path' => '/usr/sbin/sendmail -bs',
        ],

        'log' => [
            'transport' => 'log',
            'channel' => env('MAIL_LOG_CHANNEL'),
        ],

        'array' => [
            'transport' => 'array',
        ],

        'failover' => [
            'transport' => 'failover',
            'mailers' => [
                'smtp',
                'log',
            ],
        ],
    ],

'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],

'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];